获取的属性是静态的并且不会动态更新自身是什么意思?

发布于 2024-08-18 07:42:07 字数 358 浏览 6 评论 0原文

苹果在 NSFetchedPropertyDescription 类参考中说:

但请注意,与播放列表不同 获取的属性是静态的——确实如此 不动态更新自身 目标实体中的对象 改变。

很好,但这到底是什么意思:静态属性?不在目标实体更改中动态更新?

有人可以解释一下吗?

我的想法是,获取的属性用于弱引用。喜欢:播放列表可能引用歌曲,但播放列表并不“拥有”它们。如果播放列表被删除,歌曲永远不会因此而被删除。此外,这些歌曲没有对播放列表的反向引用,他们甚至不必知道它的存在。

好的,那么如果歌曲被删除,播放列表不会以任何方式通知?或者苹果想告诉我什么?

Apple says in the NSFetchedPropertyDescription class reference:

Note, however, that unlike a playlist
a fetched property is static—it does
not dynamically update itself as
objects in the destination entity
change.

Nice, but what exactly does that mean: static property? Not dynamically updating in the destination entity change?

Can someone explain that?

What I get in my head is that a fetched property is for weak references. Like: A playlist may reference songs, but the playlist doesnt "own" them. If the playlist gets deleted, the song's never get deleted as a consequence of that. Also, the songs have no back-reference to the playlist, they don't have to know that it even exists.

Ok, so if a song gets deleted, the playlist isn't notified in any way? Or what is Apple trying to tell me?

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

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

发布评论

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

评论(1

泪眸﹌ 2024-08-25 07:42:07

本质上,这意味着您必须每次手动更新获取的结果才能接收源对象的最新更改。

我刚刚查阅了您引用的文档。引用后的下一段应该说清楚:

获取的属性的效果是
类似于执行获取请求
自己并将结果放入
瞬态属性,虽然与
框架管理细节。在
特别是,获取的属性不是
获取直到被请求为止,并且
然后将结果缓存起来,直到
对象变成了故障。你用
刷新对象:合并更改:
(NSManagedObjectContext) 手动
刷新属性——这会导致
与此相关的获取请求
属性被再次执行时
接下来会触发对象错误。

Essentially it means that you have to manually update the fetched result every time to receive the latest changes of your source object.

I just consulted your quoted documentation. The next paragraph after your quote should make it clear:

The effect of a fetched property is
similar to executing a fetch request
yourself and placing the results in a
transient attribute, although with the
framework managing the details. In
particular, a fetched property is not
fetched until it is requested, and the
results are then cached until the
object is turned into a fault. You use
refreshObject:mergeChanges:
(NSManagedObjectContext) to manually
refresh the properties—this causes the
fetch request associated with this
property to be executed again when the
object fault is next fired.

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