views:

30

answers:

1

In my iPhone app, I have an NSFetchedResultsController showing User objects in a UITableView. The User Objects have 0-many Log objects. A summary of the Log objects are shown together with their User object in the UITableView.

My app uses a tab bar, so user input in the logging tab require that the user tab's NSFetchedResultsController is triggered to reload.

So far I do it by writing to the User object:

log.user = nil;
log.user = [User current]; // Same as before. Just triggering a reload.
NSError *error = nil;
[myManagedObjectContext save:&error];

This works fine, but seems a bit like a hack.

Is there a better way to do this? Like specifying that changes in the Log object should propagate to the User object too?

A: 
[myFetchedResultsController performFetch:&error];

But why would you want to do this? It should only reload when there is new data for it to fetch. If there is new data then a save of the NSManagedObjectContext is the right action.

What is your underlying goal?

Marcus S. Zarra
There *is* new data available in the Log objects. The Log objects are summarized together with the User object in the user screen.However, updating the Log object alone won't trigger a refresh of the fetched User object.
geon
In that case if you are in the relevant view controller a call to `-reloadData` would be sufficient, if not then I would have the relevant view controller listen for `NSManagedObjectContextDidSaveNotification` and refresh the table (or even narrow it down to specific cells) as needed. Your initial solution feels risky.
Marcus S. Zarra