问题
In a NSManagedObjectContextObjectsDidChangeNotification
notification, I sometimes get the NSRefreshedObjectsKey
key.
I understand refreshed objects to be a new fetch of the object from the persistent store/cache.
What causes the notification to return refreshed objects then? For inserted, updated, deleted, etc it is obvious, but what must I do to an object for it to appear in the NSRefreshedObjectsKey
key? E.g. is it that it may have simply been touched in some way (same values written to same keys)?
回答1:
if you call '- (void)refreshObject:(NSManagedObject *)object mergeChanges:(BOOL)flag ' on an object, that object wud be included in refreshed objects.
we use multiple threaded managedobject contexts, and before merging the changes from bg context, we realize all changed objects using 'existingObject'. This also causes these objects to be included for 'NSRefreshedObjectsKey' key.
来源:https://stackoverflow.com/questions/12744328/purpose-of-nsrefreshedobjectskey