我認爲這會工作,但我不知道爲什麼我做錯了。我使用的謂詞在下面的代碼已取得的成果控制器:NSFetchedResultsController委託方法不爲這些更改觸發
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription * entity = [NSEntityDescription entityForName:@"SearchResult" inManagedObjectContext:[[DataInterfaceObject sharedAlloc] managedObjectContext]];
[fetchRequest setEntity:entity];
[fetchRequest setFetchBatchSize:10];
// Results Table predicate
NSPredicate *predicate_Results = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects: [ResultsTableVC resultsPredicate], [NSPredicate predicateWithFormat:@"searchUsed.isCollapsedView == NO"], nil]];
// Favorites Table predicate
NSPredicate *predicate_Favorites = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects: [FavoritesTableVC favoritesPredicate], [NSPredicate predicateWithFormat:@"favoritesInfoLink.isCollapsedView == NO"], nil]];
// Full predicate
NSPredicate *predicate =
[NSCompoundPredicate orPredicateWithSubpredicates: [NSArray arrayWithObjects:
predicate_Results, predicate_Favorites, nil]];
[NSFetchedResultsController deleteCacheWithName:@"resultsCache"];
[fetchRequest setPredicate:predicate];
的目的是獲取匹配謂詞所有SearchResult
實體。 SearchResult實體具有如下的searchUsed
關係:SearchResult < < - > SearchTerms。 SearchTerms有一個屬性isCollapsedView
。
用戶可以點擊一個視圖並導致相應的對象視圖摺疊,並且此時searchUsed.isCollapsedView的值被更新並保存到moc中。我已經證實,這是發生。
我希望這個改變能被提取的結果控制器識別,然後委託方法會觸發,但它們不會。
委託方法在插入,刪除或更新搜索實體時觸發。
我是否有這個設置錯誤,或者我的期望錯誤?我能做些什麼呢?
是的,這將遵循我描述的行爲。有點可笑,但我想這是你可以採取的一種方法。 – gschandler 2012-07-23 05:27:57