第一個,請確保您創建您的抓取結果控制器時,瞬態屬性僅用於sectionNameKeyPath
。最好命名爲sectionIdentifier
(正如Apple在其示例代碼中所做的那樣)。實際日期應該是您實體的單獨屬性。 (我將其稱之爲dateAttribute
二,請確保您在Entity.m文件中指定的關鍵路徑依賴:
+ (NSSet *)keyPathsForValuesAffectingSectionIdentifier {
// If the value of dateAttribute changes, the section identifier may change as well.
return [NSSet setWithObject:@"dateAttribute"];
}
三,確保在你的控制器,你作出適當的反應在管理對象方面的變化通過
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{
if (!self.tableView.editing) [self.tableView reloadData];
// the quick and dirty method without animations;
// see referenced code for a more pleasant approach
}
如果有不清楚的地方,看看蘋果的例子DateSectionTitles。
如何傳播更新? NSFetchedResultsController委託? – Mundi 2012-08-04 21:07:01
是的,我認爲是。 – mhbdr 2012-08-04 21:27:28
對於SQlite商店,您可能不適用於排序描述符的瞬態屬性。 – 2012-08-05 06:55:14