NSManagedObjectContextObjectsDidChangeNotification confusion
NSManagedObjectContextObjectsDidChangeNotification confusion
- Subject: NSManagedObjectContextObjectsDidChangeNotification confusion
- From: Roland King <email@hidden>
- Date: Tue, 11 Jun 2013 21:47:14 +0800
My first time really trying to do multi-threaded Core Data ..
I have two contexts, A and B. Things are changing in A, I want to track them in B. I think I understand how the ..DidSaveNotification works with mergeChangesFromContextDidSaveNotification:, it can refresh the objects in B's context and they will be reloaded from the store they were just saved in and thus updated to match A.
I'm not sure how to use NSManagedObjectContextObjectsDidChangeNotification however, to get changes more often. When I receive one of those it has the same keys as the DidSaveNotification, however the objects haven't yet, and may not for a while, be saved in the persistent store, they are just sitting in A, so just refreshing the objects in B won't really help, they'll just be reloaded from the saved database and you'll get the old values again, not those as they are in context A.
The only way I can think this would work is if B is a child context of A, in which case the refresh would cause the updated objects to be pulled back from that, updated, context. However the DidChangeNotification completely predates child contexts by 3 iOS revisions so I must be missing something. The documentation suggests that in context B you can reload the affected objects, but I don't really see how, they aren't saved.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden