• 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: Conrad Shultz <email@hidden>
  • Date: Thu, 26 Jan 2012 16:25:49 -0800

On 1/26/12 4:21 PM, Kyle Sluder wrote:
> On Thu, Jan 26, 2012 at 2:44 PM, Conrad Shultz
> <email@hidden> 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@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>)
 >Re: ARC and blocks (From: Conrad Shultz <email@hidden>)
 >Re: ARC and blocks (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: ARC and blocks
  • Next by Date: Full-Height Toolbar Item
  • Previous by thread: Re: ARC and blocks
  • Next by thread: Re: ARC and blocks
  • Index(es):
    • Date
    • Thread