Core data 使用NSArrayController将岩芯图绑定到岩芯数据时崩溃

Core data 使用NSArrayController将岩芯图绑定到岩芯数据时崩溃,core-data,core-plot,nsarraycontroller,Core Data,Core Plot,Nsarraycontroller,我正在尝试使用核心图和绑定在核心数据中绘制数据。 我的核心数据模型: 我可以插入,所以我知道我的联系人是好的。。。但这在绑定处爆炸: [<NSArrayController 0x6000001c40b0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key measuredate. -(void)addPlotWithIdentifier:(NSString *)iden

我正在尝试使用核心图和绑定在核心数据中绘制数据。 我的核心数据模型:

我可以插入,所以我知道我的联系人是好的。。。但这在绑定处爆炸:

[<NSArrayController 0x6000001c40b0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key measuredate.

-(void)addPlotWithIdentifier:(NSString *)identifier context:(NSManagedObjectContext *)moc
{

    CPTScatterPlot *newPlot = [[CPTScatterPlot alloc] initWithFrame:graph.bounds];
    dataSourceLinePlot.identifier     = identifier;



    CPTMutableLineStyle *lineStyle = [dataSourceLinePlot.dataLineStyle mutableCopy];
    lineStyle.lineWidth              = 2.0;
    lineStyle.lineColor              = [CPTColor greenColor];
    dataSourceLinePlot.dataLineStyle = lineStyle;


    CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
    plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(1380243600)
                                                    length:CPTDecimalFromFloat(1382835600)];
    plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0)
                                                     length:CPTDecimalFromFloat(100)];

    [dataSourceLinePlot setPlotSpace:plotSpace];
    NSLog(@"Create a controller");
    NSArrayController *newController=[[NSArrayController alloc] initWithContent:nil];
    NSLog(@"MOC: set context");
    [newController setManagedObjectContext:moc];
    NSLog(@"MOC: set Entity");
    [newController setEntityName:@"BM_Measure"];
    NSLog(@"MOC: set Editable");
    [newController setEditable:FALSE];
    NSLog(@"MOC: set sort descriptors");
    [newController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"measuredate" ascending:YES]]];
    NSLog(@"MOC: fetch");

    [newController setAutomaticallyPreparesContent:TRUE];
    [newController setAutomaticallyRearrangesObjects:TRUE];
    NSError *error;
    if ([newController  fetchWithRequest:nil merge:NO error:&error] == NO){
        NSLog(@"Couldnt fetch");
    }
    NSLog(@"%@",newController);

    NSLog(@"Bind x");
    [newPlot bind:CPTScatterPlotBindingXValues toObject:newController withKeyPath:@"measuredate" options:nil];
    NSLog(@"Bind y");
    [newPlot bind:CPTScatterPlotBindingYValues toObject:newController withKeyPath:@"measurevalue" options:nil];
    NSLog(@"Save Objects");

    [g_Plots addObject:newPlot];
    [g_ArrayControllers addObject:newController];
    [graph addPlot:newPlot];
    NSLog(@"Added... %ld",[g_Plots count]);



}
[valueForUndefinedKey:]:该类不符合密钥测量数据的键值编码。
-(void)addPlotWithIdentifier:(NSString*)标识符上下文:(NSManagedObjectContext*)moc
{
cptspatterplot*newPlot=[[cptspatterplot alloc]initWithFrame:graph.bounds];
dataSourceLinePlot.identifier=标识符;
CPTMutableLineStyle*lineStyle=[dataSourceLinePlot.dataLineStyle mutableCopy];
lineStyle.lineWidth=2.0;
lineStyle.lineColor=[CPTColor greenColor];
dataSourceLinePlot.dataLineStyle=线型;
CPTXYPlotSpace*plotSpace=(CPTXYPlotSpace*)graph.defaultPlotSpace;
plotSpace.xRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(1380243600)
长度:CPTDecimalFromFloat(138285600)];
plotSpace.yRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0)
长度:CPTDecimalFromFloat(100)];
[dataSourceLinePlot setPlotSpace:plotSpace];
NSLog(@“创建控制器”);
NSArrayController*新控制器=[[NSArrayController alloc]initWithContent:nil];
NSLog(@“MOC:设置上下文”);
[newController setManagedObjectContext:moc];
NSLog(@“MOC:集合实体”);
[newController setEntityName:@“BM_度量”];
NSLog(@“MOC:设置为可编辑”);
[newController setEditable:FALSE];
NSLog(@“MOC:设置排序描述符”);
[newController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor SortDescriptor WithKey:@“measuredate”升序:是]];
NSLog(@“MOC:fetch”);
[newController setautomaticallypreprescontent:TRUE];
[newController setAutomaticallyrarrangesobjects:TRUE];
n错误*错误;
if([newController fetchWithRequest:nil merge:NO error:&error]==NO){
NSLog(@“无法获取”);
}
NSLog(@“%@”,新控制器);
NSLog(@“绑定x”);
[newPlot bind:cptspatterplotbindingxvalues to object:newController with keypath:@“measuredate”选项:nil];
NSLog(@“绑定y”);
[newPlot bind:cptspatterplotbindingValues to object:newController with keypath:@“measurevalue”选项:nil];
NSLog(@“保存对象”);
[g_Plots addObject:newPlot];
[g_ArrayController添加对象:newController];
[图形addPlot:newPlot];
NSLog(@“添加…%ld”,[g_绘图计数]);
}

核心绘图绑定需要数据数组。这是CPTTestap示例应用程序中的绑定代码:

[boundLinePlot bind:CPTScatterPlotBindingXValues
           toObject:self 
        withKeyPath:@"arrangedObjects.x"
            options:nil];
[boundLinePlot bind:CPTScatterPlotBindingYValues
           toObject:self
        withKeyPath:@"arrangedObjects.y"
            options:nil];

那么你是说它不适用于CoreData?我必须将核心数据信息提取到NSArray中?我想更重要的是,有没有使用核心数据源将核心图绘制到任何地方的例子?@JeremyLaurenson:您也可以实现数据源方法,并在那里查询核心数据存储中的值。与绑定不同,但也可以工作。啊,是的,您当然可以实现一个小的NSController对象,该对象可以执行此操作,但可以绑定。您是否应该绑定到
newController.arrangedObjects