2011-02-09 96 views
3

我有一個模型,其中包含通過一對一關係鏈接的兩個實體。我想在TableView中顯示entityB.myIntAttribute等於給定值的所有EntityA對象。當我使用謂詞@「entityB.myIntAttribute == aValue」爲EntityA創建FetchRequest時,這將起作用。NSFetchedResultsController更改跨關係的跟蹤

我的問題是更改跟蹤。我在與之前的FetchRequest關聯的NSFetchedResultsController上設置了一個NSFetchedResultsControllerDelegate委託。這個委託的工作原理是,如果我設置了一個新的entityB,該新的entityB與其中一個結果的謂詞不匹配,它會得到刪除的通知。但是,如果我直接更改entityB對象上myIntAttribute的值,以便謂詞結果發生更改,則不會通知我的委託進行更改。

NSFetchedResultsController是否使用貫穿關係的謂詞更改跟蹤工作?在修改關係屬性後,FetchedResultController如何重新計算謂詞?

+0

見我的回答如下,註釋不會讓我再補充足夠的字符 – afrederick 2012-01-12 16:06:54

回答

-1

你實現一切都在你的委託下列方法:

- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type 

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath 

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller 

- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller