Re: ARC and blocks
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