I have following relationship hierarchy between core-data entities (managed objects):
Entity1 > Entity2 > Entity3
There's a one-to-one relationship between Entity1
and Entity2
, and one-to-many relationship between Entity2
and Entity3
.
I have a view controller that displays a list of Entity1
records, using NSFetchedResultsController
. The UITableViewCell
shows information from Entity1
, Entity2
and Entity3
. Now, the NSFetchedResultsControllerDelegate
methods are automatically called when Entity1
object is added/updated/deleted, BUT when the related Entity2
or Entity3
records are added/updated/deleted, the delegate methods are not called.
In this situation, what's the best or possible way to recognize that related records have been updated, and that UITableViewCell
needs to be updated as well?
You need to make dirty the properties of the other entities. In other words, you should call
[self willChangeValueForKey:@"someProperty"];
[self didChangeValueForKey:@"someProperty"];
on the entities you want to update.
Here a sample solution that makes possible what you want to achieve.
NSFetchedResultsController pitfall
Hope that helps.