• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ARC Retain Cycles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC Retain Cycles


  • Subject: Re: ARC Retain Cycles
  • From: Andy Lee <email@hidden>
  • Date: Mon, 21 Apr 2014 19:03:20 -0400

On Apr 21, 2014, at 5:18 PM, Kevin Meaney <email@hidden> wrote:

> On 21 Apr 2014, at 21:09, Andy Lee <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


References: 
 >ARC Retain Cycles (From: Dave <email@hidden>)
 >Re: ARC Retain Cycles (From: Cody Garvin <email@hidden>)
 >Re: ARC Retain Cycles (From: Quincey Morris <email@hidden>)
 >Re: ARC Retain Cycles (From: Dave <email@hidden>)
 >Re: ARC Retain Cycles (From: Quincey Morris <email@hidden>)
 >Re: ARC Retain Cycles (From: Dave <email@hidden>)
 >Re: ARC Retain Cycles (From: Roland King <email@hidden>)
 >Re: ARC Retain Cycles (From: Dave <email@hidden>)
 >Re: ARC Retain Cycles (From: Andy Lee <email@hidden>)
 >Re: ARC Retain Cycles (From: Alex Zavatone <email@hidden>)
 >Re: ARC Retain Cycles (From: Andy Lee <email@hidden>)
 >Re: ARC Retain Cycles (From: Kevin Meaney <email@hidden>)

  • Prev by Date: Re: NSOperation Issues
  • Next by Date: Re: Strange toolbar/view/resize cursor interaction
  • Previous by thread: Re: ARC Retain Cycles
  • Next by thread: Re: ARC Retain Cycles
  • Index(es):
    • Date
    • Thread