我正在使用Coreplot API创建条形图。当我尝试作为单个项目运行相同的代码时,它运行良好,但是当我将其集成到UINavigationController
中的项目中时,这给我一个错误。GraphView.h
@interface GraphView : CPTGraphHostingView <CPTPlotDataSource, CPTPlotSpaceDelegate>
{
CPTXYGraph *graph;
NSArray *dates;
}
@property(nonatomic, retain) NSArray *dates;
GraphView.m
dates = [NSArray arrayWithObjects:@"2012-05-01", @"2012-05-02", @"2012-05-03",
@"2012-05-04", @"2012-05-05", @"2012-05-06", @"2012-05-07", @"2012-05-08", @"2012-05-09",@"2012-05-10",@"2012-05-11",@"2012-05-12",@"2012-05-13",@"2012-05-14",@"2012-05-15",@"2012-05-16",@"2012-05-17",@"2012-05-18",@"2012-05-19",@"2012-05-20",nil];
- (NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
{
return dates.count;
}
在返回dates.count,它给了我错误。
[__NSArrayI count]:发送到已释放实例0x6dbfd10的消息
最佳答案
您正在创建一个自动释放对象。将内存分配给日期数组。
dates = [[NSArray alloc]initWithObjects:@"2012-05-01", @"2012-05-02", @"2012-05-03",
@"2012-05-04", @"2012-05-05", @"2012-05-06", @"2012-05-07", @"2012-05-08", @"2012-05-09",@"2012-05-10",@"2012-05-11",@"2012-05-12",@"2012-05-13",@"2012-05-14",@"2012-05-15",@"2012-05-16",@"2012-05-17",@"2012-05-18",@"2012-05-19",@"2012-05-20",nil];
关于iphone - [__NSArrayI count]:发送到已释放实例0x6dbfd10的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13006526/