Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why controllerDidChangeContent is not being called?

Here is a simple scenario: assuming I have two Core Data entities: A and B with one to many relationship. (A can point to many B). When creating NSFetchedResultsController fetching all A objects, changing a property of any A object will trigger controllerDidChangeContent delegate method. However, changing a property of B object will not trigger this method. (although the changed B object is referenced by one of the A objects)

Any idea why?

like image 718
Joshua Avatar asked Feb 22 '23 09:02

Joshua


1 Answers

This took some time to get my head around it. The fetched results controller evaluates the changes of its managed object context. Those changes only fire the fetched results controller delegate methods if they would meet the criteria set for its fetch. This includes matching the predicate conditions.

If your controller is fetching entities of type A, then it will only react to changes of entities of type B if those changes to B affect what is in A (and matching the predicate conditions abd maybe the sort descriptors, as well).

Can you show the predicate in your question above? Can you show the relationships between A and B?

like image 153
Jim Avatar answered Mar 05 '23 07:03

Jim