ios – NSManagedObject的保留周期仍然可能吗?

根据文档,我们有一些麻烦:内存泄漏.
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdMemory.html

Breaking Relationship Strong Reference Cycles

When you have relationships between managed objects, each object
maintains a strong reference to the object or objects to which it is
related. This can cause strong reference cycles. To ensure that
reference cycles are broken, when you’re finished with an object you
can use the managed object context method refreshObject:mergeChanges:
to turn it into a fault.

You typically use refreshObject:mergeChanges: to refresh a managed
object’s property values. If the mergeChanges flag is YES, the method
merges the object’s property values with those of the object available
in the persistent store coordinator. If the flag is NO, however, the
method simply turns an object back into a fault without merging, which
causes it to break strong references to related managed objects. This
breaks the strong reference cycle between that managed object and the
other managed objects.

Note that, of course, before a managed object can be deallocated there
must be no strong references to it, including from outside of Core
Data. See also Change and Undo Management.

但.没有任何Apple的代码示例可以解决此问题.
我已经检查过TopSongs,iPhoneCoreDataRecipes,CoreDataBooks,ThreadedCoreData示例项目,但是他们都没有关注这个问题.是否意味着对象关系现在很短暂?

最佳答案 对象关系并不弱.但是我们现在正在使用ARC,它知道如何正确处理这些参考周期.

注意:该文档是旧的,我建议阅读更新的指南.

点赞