geon
geon

Reputation: 8469

How do I trigger a reload in an NSFetchedResultsController without changing the fetched object?

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?

Upvotes: 2

Views: 1030

Answers (1)

Marcus S. Zarra
Marcus S. Zarra

Reputation: 46718

[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?

Upvotes: 2

Related Questions