我想不出核心数据指的是核心数据之外的任何东西。所以没有办法会出现引用循环。至多核心数据对象指向另一个核心数据对象。
然而,我可能是错的。
Managedobjectcontext 不持有对核心数据的强引用。
这里有指南吗?
最佳答案
Is there any guide here?
这里是 Core Data Programming Guide: Object Lifetime Management 的链接.
它是在 2014 年 7 月更新的,因此它可能有您提出此问题时未发布的新信息。
By default, though, the references between a managed object and its context are weak. This means that in general you cannot rely on a context to ensure the longevity of a managed object instance, and you cannot rely on the existence of a managed object to ensure the longevity of a context. Put another way, just because you fetched an object doesn’t mean it will stay around.
The exception to this rule is that a managed object context maintains a strong reference to any changed
这意味着您对 NSManagedObject 子类(核心数据对象)的引用应该是strong
。
关于objective-c - 对核心数据对象的引用应该是强引用还是弱引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16479232/