NSFetchedResultsController change tracking across relationship
I have a model with two entities linked by a to-one relationship. I want to display in a TableView all EntityA objects where entityB.myIntAttribute equals a given value. This works when I create a FetchRequest for EntityA with the predicate @"entityB.myIntAttribute == aValue".
My problem is with change tracking. I have set a NSFetchedResultsControllerDelegate delegate on the NSFetchedResultsController associated to the previous FetchRequest. This delegate works because it gets notified of a deletion if I set a new entityB that doesn't match the predicate on one of the results. But if I change directly the value of myIntAttribute on the entityB object so that the predicate result changes, my delegate is not notified of the change.
Does NSFetchedResultsController change tracking work with a predicate that goes across a relationship ? How can the FetchedResultController recompute the predicate after modifica开发者_运维技巧tion of an attribute of the relationship ?
Are you implementing all of the following methods in your delegate:
- (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
精彩评论