Chandu
Chandu

Reputation: 695

Warning while executing code for CorePlot

- (void)viewDidLoad
{
graph = [[CPTXYGraph alloc] initWithFrame: self.view.bounds];   
CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
hostingView.hostedGraph = graph;
CPTPieChart *pieChart = [[CPTPieChart alloc] init];
pieChart.dataSource = self;
pieChart.pieRadius = 100.0;
pieChart.identifier = @"PieChart1";
pieChart.startAngle = M_PI_4;
pieChart.sliceDirection = CPTPieDirectionCounterClockwise;

self.pieData=   [NSMutableArray arrayWithObjects:[NSNumber numberWithDouble:90.0], 
                [NSNumber numberWithDouble:20.0],
                [NSNumber numberWithDouble:30.0],
                [NSNumber numberWithDouble:40.0],
                [NSNumber numberWithDouble:50.0], 
                [NSNumber numberWithDouble:60.0], nil];

CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[graph applyTheme:theme];
[graph addPlot:pieChart];
[pieChart release];
}

I found this code on the net.This Code is working fine but am getting two warnings at
pieChart.dataSource = self;

It says.

warning: class 'SOTC_CorePlotExampleViewController' does not implement the 'CPTPlotDataSource' protocol

warning: Semantic Issue: Assigning to 'id' from incompatible type 'SOTC_CorePlotExampleViewController *'

Upvotes: 0

Views: 545

Answers (3)

Tendulkar
Tendulkar

Reputation: 5540

you have to import the protocols in .h file "CPTPlotDataSource" like @interface:UIViewController < CPTPlotDataSource >

Upvotes: 0

Michael Dautermann
Michael Dautermann

Reputation: 89509

add <CPTPlotDataSource> to the end of your custom view controller's declaration in your @interface (.h) file:

@interface YourViewController  : UIViewController <CPTPlotDataSource>

(change YourViewController in my example to whatever the name of your view controller is)

Upvotes: 2

Manali
Manali

Reputation: 573

Did you do this?

@interface viewController : UIViewController <CPTPlotDataSource> 

viewController needs to implement the said protocol

Upvotes: 1

Related Questions