iphone - 执行 CorePlot 代码时出现警告

标签 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;

它说。

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

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

最佳答案

添加<CPTPlotDataSource>到您的@interface (.h) 文件中自定义 View Controller 声明的末尾:

@interface YourViewController  : UIViewController <CPTPlotDataSource>

(将我示例中的 YourViewController 更改为您的 View Controller 的名称)

关于iphone - 执行 CorePlot 代码时出现警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8267629/

相关文章:

ios - 静态快速​​操作在 Objective C iOS 中不起作用

ios - 在 Swift 中点击返回键时,如何关闭 UIAlertController?

iphone - 即使安装了 iOS 5 模拟器也无法测试

iPhone - 带有 html 内容的 UITextView?

iphone - 如何在 UIToolbar 上拥有多行项目?

ios - viewDidAppear 运行,然后不运行。

ios - SKLightNode 性能问题

xcode - 应用程序包不包含有效标识符

iphone - 来自 iphone 应用程序的定位服务

iphone - 如何维护 TableView 中行的选择状态?