• 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: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"


  • Subject: Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"
  • From: Sean McBride <email@hidden>
  • Date: Mon, 09 Jul 2012 17:51:39 -0400
  • Organization: Rogue Research Inc.

On Mon, 9 Jul 2012 11:03:50 -0500, Fritz Anderson said:

>You correctly describe the cycle. In practice, NSOperationQueue probably
>releases the block when it's done with it, and breaks the cycle, but
>clang can't know that, so it has to warn of the "likely" cycle.
>
>You can break this by having a strong reference to self that the block
>can manage independently.
>
>   __block MyClass *      blockSelf = self;
>   [self.operationQueue addOperationWithBlock:^{
>       [blockSelf bar];
>       blockSelf = nil;
>   }];

A contortion I guess those of us switching from GC to ARC will have to sprinkle around. :(  Shame.

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada



_______________________________________________

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: 
 > "Capturing 'self' strongly in this block is likely to lead to a retain cycle" (From: Andreas Grosam <email@hidden>)
 >Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle" (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: NSInteger vs int vs int32_t
  • Next by Date: Re: Arrgh IB constraints
  • Previous by thread: Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"
  • Next by thread: Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"
  • Index(es):
    • Date
    • Thread