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 (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