2013-10-24 3 views
2

코어 플롯 및 바인딩을 사용하여 코어 데이터에 데이터를 그래프로 표시하려고합니다. 내 핵심 데이터 모델 :NSArrayController를 사용하여 코어 데이터에 코어 플롯 바인딩이 충돌했습니다.

enter image description here

내가 삽입 할 수 있어요, 그래서 내 이름과 전화 번호가 ... 잘 알고 있지만, 바인딩에서이 폭탄 : 기대 바인딩

[<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]); 



} 
+0

당신의 newController.arrangedObjects''에있을 결합한다 :이 CPTTestApp 예를 들어, 응용 프로그램에서 바인딩 코드? –

답변

0

핵심 플롯 데이터 배열

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

CoreData에서 작동하지 않는다고 말하는 것입니까? NSArrays에 핵심 데이터 정보를 추출해야합니까? – JeremyLaurenson

+0

핵심 데이터 소스를 사용하여 코어 플롯의 모든 예제를 그래프로 나타낼 수 있습니까? – JeremyLaurenson

+0

@JeremyLaurenson : 대신 데이터 소스 메서드를 구현하고 coredata 저장소에 값을 쿼리 할 수도 있습니다. 바인딩과 같지 않지만 작동합니다. 아 그래, 당신은 물론 이것을 할 수 있지만 바인딩 할 수있는 작은 NSController 개체를 구현할 수 있습니다. –