执行CorePlot代码时发出警告

时间:2011-11-25 10:23:46

标签: iphone ios xcode core-plot

- (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];
}

我在网上找到了这个代码。这个代码工作正常,但是在第二天有两个警告       pieChart.dataSource = self;

它说。

  

警告:类'SOTC_CorePlotExampleViewController'没有   实施'CPTPlotDataSource'协议

     

警告:语义问题:从'分配'id'   不兼容的类型'SOTC_CorePlotExampleViewController *'

3 个答案:

答案 0 :(得分:2)

<CPTPlotDataSource>添加到@interface(.h)文件中自定义视图控制器声明的末尾:

@interface YourViewController  : UIViewController <CPTPlotDataSource>

(将我的示例中的YourViewController更改为视图控制器的名称)

答案 1 :(得分:1)

你做到了吗?

@interface viewController : UIViewController <CPTPlotDataSource> 

viewController需要实现所述协议

答案 2 :(得分:0)

你必须在.h文件“CPTPlotDataSource”中导入协议,如@interface:UIViewController < CPTPlotDataSource >