CoreData addObserver NSKeyValueChangeInsertion

发布于 2024-10-07 05:43:29 字数 151 浏览 0 评论 0原文

有没有办法获取在 NSManagedObject 上使用 addObserver:forKeyPath:options:context: 和选项 NSKeyValueChangeInsertion 添加的对象?

Is there a way to get the object that has been added using addObserver:forKeyPath:options:context: with option NSKeyValueChangeInsertion on an NSManagedObject?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌上芳菲 2024-10-14 05:43:29

是的。从 observeValueForKeyPath:ofObject:change:context: 的文档中:

change 一个字典,描述相对于对象的键路径 keyPath 处的属性值所做的更改。条目在“更改字典使用的键”中进行了描述。

再往下:

NSKeyValueChangeKindKey
一个 NSNumber 对象,包含与 NSKeyValueChangeKindKey 枚举之一相对应的值,指示发生了何种类型的更改。

NSKeyValueChangeIndexesKey
如果 NSKeyValueChangeKindKey 条目的值为 NSKeyValueChangeInsertion、NSKeyValueChangeRemoval 或 NSKeyValueChangeReplacement,则该键的值为 NSIndexSet 对象,其中包含插入、删除或替换对象的索引。

Yes. From the documentation for observeValueForKeyPath:ofObject:change:context::

change A dictionary that describes the changes that have been made to the value of the property at the key path keyPath relative to object. Entries are described in “Keys used by the change dictionary.”

And further down:

NSKeyValueChangeKindKey
An NSNumber object that contains a value corresponding to one of the NSKeyValueChangeKindKey enumerations, indicating what sort of change has occurred.

NSKeyValueChangeIndexesKey
If the value of the NSKeyValueChangeKindKey entry is NSKeyValueChangeInsertion, NSKeyValueChangeRemoval, or NSKeyValueChangeReplacement, the value of this key is an NSIndexSet object that contains the indexes of the inserted, removed, or replaced objects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文