Reputation: 1491
If I have 3 NSManagedObjectContexts.
A. is the root context.
B. is a background saving context that generates NSManagedObjects after parsing a JSON
C. is a child context that is used in a NSFetchedResultsController
layout is like this
A
/ \
B C
When I make changes in B, i tell B to save, then I tell B.parent to save. My thoughts are that it would trigger C to send updates to my UITableView that its backing.
Is my theory correct? or is there something else I need to do to get C to see the updates from A. I am wanting the changes to pop into the tableview as they are made.
Specifically, I am trying to understand how these children respond to changes in their parent contexts and how this causes NSFetchedResultsController to trigger updates.
Upvotes: 2
Views: 326
Reputation: 3598
As saving only pushes changes one level up, the children of a managedObjectContext will get the changes made on their parent context only when you fetch again.
For more informations about how nested contexts work, checkout the video What's New in Core Data for iOS from the WWDC 2011.
Anyway, in your example, if A is writing and reading in/from the database, and B, why don't you make C a child of B? This way, saving C will also update the UI while saving B will push the changes and queue them for saving.
Upvotes: 1