简体   繁体   English

领域和iOS保留周期

[英]Realm and iOS Retain Cycles

Does realm properly handle entities that have a parent-child relationship (eg the child holds a reference to the parent)? 领域是否正确处理具有父子关系的实体(例如,孩子持有对父母的引用)? The documentation states that Realm ignores the property modifiers (nonatomic, weak, ...), so I basically don't have control of this. 文档说明Realm忽略属性修饰符(非原子,弱,...),所以我基本上无法控制它。

For standalone objects (ie objects created with [[MyClass alloc] init] which have not been added to a Realm afterwards) the normal rules apply, and you'll need to use a weak property to break the retain cycle if you're constructing graphs of standalone objects. 对于独立对象(即使用[[MyClass alloc] init]创建的对象(之后尚未添加到Realm))正常规则适用,如果您正在构建,则需要使用weak属性来中断保留周期独立对象的图形。

For objects persisted in a Realm, accessing RLMObject -subclass properties actually creates a new object each time rather than caching the accessor object. 对于持久存在于Realm中的对象,访问RLMObject -subclass属性实际上每次都会创建一个新对象,而不是缓存访问者对象。 This means that the objects never actually hold references to any other in-memory objects, so there can't be a retain cycle. 这意味着对象永远不会实际保存对任何其他内存中对象的引用,因此不能有保留周期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM