Clarification regarding "Retain Cycle" in the documentation.
I found this from the following documentation. http://fbinfer.com/docs/infer-bug-types.html#RETAIN_CYCLE
The Retain Cycle is described as follows.
@class Child; @interface Parent : NSObject { Child *child; } @end @interface Child : NSObject { __weak Parent *parent; } @end
But I think, this is valid if "Child" is a subclass of "Parent". Here both Child and Parent are inherited from NSObject class and hence are independent. I think the documentation should be corrected as follows.
@class Child; @interface Parent : NSObject { Child *child; } @end @interface Child : Parent { __weak Parent *parent; } @end
Please correct me if I am wrong.
No, Child and Parent don't need to be inherited from each other for there to be a retain cycle. If parent has a property child that is strong, and Child has a strong property parent, then you will get a cycle parent -> child -> parent, that cannot be deallocated.