views:

81

answers:

1

I am running into an issue similar to the one described here: http://stackoverflow.com/questions/1319940/nsfetchedresultscontrollerdelegate-not-firing (the delegate for my NSFetchedResultsControllerDelegate are not being called on my second view controller)

I can't seem to get the proposed solutions to work. I have a main view that loads information from Core Data just fine, but when it pushes a separate controller (and passes the managed object to it), the delegate methods won't fire. I've read about 'mergeChangesFromContextDidSaveNotification' but I don't understand how to synchronize the two manage objects and/or get the delegate methods to be called.

Any help would be greatly appreciated. Thank you, Mike

+1  A: 

Note sure I understand your problem exactly but a NSFetchedResultsController only calls its delegate when something changes in the part of the Core Data object graph that the controller monitors. Simply passing a managed object between two view controllers doesn't change the Core Data graph itself and therefore does not fire the the delegate methods.

To fire the delegate you have to make a change to the data that the fetchedResults controller monitors. This means changing one of entities that the fetchedResults controller fetches. You either have to add or remove an instance of an entity or you have to change an attribute or relationship of an existing entity.

...but I don't understand how to synchronize the two manage objects and/or get the delegate methods to be called.

From your description, you don't have two managed objects but just one that is passed from the first view controller to the next. Perhaps you meant managed object context?

mergeChangesFromContextDidSaveNotification:

... is a method of NSManagedObjectContext and is only used when you have need to combine the data from two separate context. That is an advanced operation that you only use when you are trying to integrate the data of two independent context. For example, when you are updating a database to a new version.

TechZen
Thank you for the clarification. I forgot to mention that I was deleting data from the UITableView which gets it data from the FetchedResultsController. The delegate methods weren't being called, even though the data was being deleted. The entry was deleted from Core data, but not the UITableView. I thought the problem was that I was passing the ManagedObjectContext object from one view to another, but I was able to solve it by simply subscribing to the notification you mentioned and calling a [tableView reloadData];
MTBPatriot