On 1/26/12 4:21 PM, Kyle Sluder wrote: > On Thu, Jan 26, 2012 at 2:44 PM, Conrad Shultz > <[email protected]> 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).
D'oh. Thanks for the pointer (no pun intended). I guess I still have some reading to do about ARC... I thought that keeping the various __bridge attributes straight was hard enough, now I have to go read up on interaction with blocks too. -- Conrad Shultz Synthetiq Solutions www.synthetiqsolutions.com _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
