NSManagedObjectContextObjectsDidChangeNotification confusion

  • 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.
  • I haven't comprehended your whole situation, but maybe there is some event you could hook in to and trigger -processPendingChanges in context A.  That usually shakes things up.
previous month june 2013 next month
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today