CoreData not documented UserInfo Notification

Hello,

the last days I was trying to solve a bug in my Unit Tests related to the CoreData "NSManagedObjectContextObjectsDidChange" Notification.

Im using some kind of Notification handler to save and abstract that for the UI and while the tests are running this notification was triggered with objects that doesn't exists anymore, which has resulted in a crash.

After some debugging I have detected, that the objects in here are really old. The objects here was from few tests ago, where a Merge Conflict happened. In the meantime there was a plenty of resets and deletes of the whole db. I have also seen that the bad notification is the first in the stack trace of the main thread, which is in my opinion also not usual.

So the real question is: The only difference what I have found for the bad notification to the real notification, was the existence of the key "NSObjectsChangedByMergeChangesKey" in the UserInfo dictionary of the ObjectsDidChange Notification. But this key is nowhere found in the documentation of Apple. Also the search engines does not produce any result. So what is this key and when is this key contained in this notification and when not?

Maybe if I understand this, it helps me to understand the overall issue ...

As far as I can tell, the value of NSObjectsChangedByMergeChangesKey, if not nil, indicates that some changes being merged to the managed object context were actually made at earlier time (but the merge was deferred for reason). I'm unclear what can trigger the deferring, however. If you have a reproducible case, I'll be interested in taking a closer look.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

CoreData not documented UserInfo Notification
 
 
Q