• 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 and blocks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC and blocks


  • Subject: Re: ARC and blocks
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 26 Jan 2012 14:47:16 -0800

On Jan 26, 2012, at 1:51 PM, Jan E. Schotsman wrote:

> Supposedly this avoids a retain cycle. But where is the cycle? At least two objects are needed for a cycle. What is the second one?

The block. When a block is copied (which it has to be, in order to be called later after the calling function has returned) it becomes a bona fide object. And this object retains objects in variables that are referred to in the block's code; myController in this case. And since myController presumably has a reference to the block too (so that it can call it), you have a cycle. The extra line to set "myController = nil" at the end breaks the cycle.

—Jens


_______________________________________________

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 and blocks (From: "Jan E. Schotsman" <email@hidden>)

  • Prev by Date: Re: ARC and blocks
  • Next by Date: Re: ARC and blocks
  • Previous by thread: Re: ARC and blocks
  • Next by thread: Re: ARC and blocks
  • Index(es):
    • Date
    • Thread