views:

24

answers:

2

I have a UITableViewController fetching a collection of objects A with a NSFetchedResultsController.

This works well and if these objet A's properties are updated, the UITableViewCell for A reflects the change.

The problem: this object has a relationship A->[B1, B2, B3...]. The cell is using some of the B's properties in its display. If I update one of the B's properties, the UITableViewCell doesn't reflects the change.

How can I make the cell change when I update one of the B, without reloading the whole tableview. Is there a way to mark an object to update?

+1  A: 

You could register for NSManagedObjectContextObjectsDidChangeNotification and examine the NSUpdatedObjectsKey value in the userInfo dictionary. If one of the updated objects is B1, B2, B3, etc., then follow its inverse relationship to determine which A object has "changed." You can determine the index of the "changed" A by finding it in NSFetchedResultsController's fetchedObjects array. And then, finally, call reloadRowsAtIndexPaths:withRowAnimation: on the UITableView.

James Huddleston
A: 

I will try James answer. I also found that using refreshObject:mergeChanges: on A would trigger reloading of this object. Is it ok to do that?

Kamchatka