本文介绍了NSRefreshedObjectsKey 的用途的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NSManagedObjectContextObjectsDidChangeNotification 通知中,我有时会收到 NSRefreshedObjectsKey 键.

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.

是什么导致通知返回刷新的对象呢?对于插入、更新、删除等,这是显而易见的,但是我必须对对象做什么才能使其出现在 NSRefreshedObjectsKey 键中?例如.是不是它可能只是以某种方式被触及(相同的值写入相同的键)?

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)?

推荐答案

如果调用 '- (void)refreshObject:(NSManagedObject *)object mergeChanges:(BOOL)flag' 在一个对象上,该对象将包含在刷新的对象中.

if you call '- (void)refreshObject:(NSManagedObject *)object mergeChanges:(BOOL)flag' on an object, that object wud be included in refreshed objects.

我们使用多线程管理对象上下文,并且在合并来自 bg 上下文的更改之前,我们使用existingObject"来实现所有改变的对象.这也会导致这些对象被包含在内用于NSRefreshedObjectsKey"键.

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 includedfor 'NSRefreshedObjectsKey' key.

这篇关于NSRefreshedObjectsKey 的用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 05:52