On Thu, Jan 26, 2012 at 2:44 PM, Conrad Shultz
<con...@synthetiqsolutions.com> wrote:
> However, __block variables are NOT retained automatically by a block
> during capture, so this breaks the retain cycle.

__block variables *are* retained under ARC:
http://clang.llvm.org/docs/AutomaticReferenceCounting.html#misc.blocks

The important bit of the code that Jan cited isn't that myController
is annotated with __block, it's that the block nils out the
myController variable when it executes.

This works because the block is a completion handler—it's only
executed once, so there's a sensible time for it to engage in cleanup.
Long-lived block arguments, however, need a different strategy. This
is why the Transitioning to ARC Release Notes also recommend
strategies that use __weak (or __unsafe_unretained if you're targeting
older OSes).

--Kyle Sluder

_______________________________________________

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