On Apr 21, 2014, at 5:18 PM, Kevin Meaney <k...@yvs.eu.com> wrote:

> On 21 Apr 2014, at 21:09, Andy Lee <ag...@mac.com> wrote:
>> 
>> The solution is to use a weak reference for one of the properties in the 
>> cycle.  In general, if one object conceptually "owns" the other, then the 
>> "owning" object uses a weak reference and the "owned" object uses a strong 
>> one.  For example, a parent has weak references to its children, and the 
>> children have strong references back to the parent.  Similarly, a delegating 
>> object has a weak reference to its delegate, which typically (though not 
>> necessarily) has a strong reference back to the delegator.
> 
> Unless I'm being confused here by your wording. Your recommendation in 
> relation to the parent child relationship is completely turned around from 
> what Apple suggests:
> 
> https://developer.apple.com/library/ios/releasenotes/objectivec/rn-transitioningtoarc/introduction/introduction.html
> See section: Use Lifetime Qualifiers to Avoid Strong Reference Cycles
> 
> If you are recommending an alternative to what Apple suggests I'd be quite 
> interested into hearing the reasons. Do you implement an array of weak 
> references to a list of children?

No, you got it right and I got it backwards.  The "owning" reference is the 
strong one -- so, for example, a regular array of children does the right 
thing.  My apologies.

--Andy

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to