【问题标题】:NSFetchRequest includesPendingChanges and propertiesToFetchNSFetchRequest 包括 PendingChanges 和 propertiesToFetch
【发布时间】:2012-02-27 22:08:15
【问题描述】:

有没有办法获取数据的特定列/属性,例如(日期)在使用挂起更改选项时从我的对象中获取?

我希望能够搜索尚未保存的待处理更改,但我也只想要一个特定的列。我不需要整个对象。我基本上想获得不同的日期并将它们返回到一个数组中。

另一种选择是只获取整个对象,但如果可能的话,可以使用 includePendingChanges 和 Distinct。

【问题讨论】:

    标签: objective-c ios5 nspredicate nsfetchrequest


    【解决方案1】:

    我最终使用了基于代码hereNSFetchController。我的 fetch 控制器是这样的。

    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:[[DataManager sharedInstance] managedObjectContext] sectionNameKeyPath:@"date" cacheName:@"List"];
    

    这会根据日期对我的所有对象进行分组,因此当我需要唯一日期时,我只需要调用[fetchedResultsControllers sections]

    【讨论】:

      猜你喜欢
      • 2012-12-28
      • 1970-01-01
      • 1970-01-01
      • 2011-04-02
      • 2021-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多