代码之家  ›  专栏  ›  技术社区  ›  Ian Turner

使用NSAccredite遍历多个核心数据对象

  •  0
  • Ian Turner  · 技术社区  · 17 年前

    我对Cocoa中的核心数据模型有问题。这可能是一个相当基本的问题。下面显示了我的核心数据模型的一部分。给定OutputCell实体中单元格属性的值,我想返回相关的直方图栏。

    Share photos on twitter with Twitpic

    NSEntityDescription *histogramBarEntityDescription = [NSEntityDescription entityForName:@"HistogramBar" 
                                                                    inManagedObjectContext:[theDocument managedObjectContext]];
    NSFetchRequest *histogramBarRequest = [[[NSFetchRequest alloc] init] autorelease];
    [histogramBarRequest setEntity:histogramBarEntityDescription];
    NSPredicate *histogramBarPredicate = [NSPredicate predicateWithFormat:@"(histogram.outputCell.cell = %@)", theOutputCell];
    [histogramBarRequest setPredicate:histogramBarPredicate];
    NSError *histogramBarError = nil;
    NSArray *histogramsArray = [[theDocument managedObjectContext] executeFetchRequest:histogramBarRequest 
         error:&histogramBarError];
    

    谢谢你的帮助。

    1 回复  |  直到 9 年前
        1
  •  2
  •   Ian Turner    17 年前

    我的问题解决了,代码中的一个流氓注释阻止了HistogramBar实体的创建。在这种情况下,对一些NSLog的详细检查有助于发现问题。

    推荐文章