I get the mentioned warning in my code and I'm wondering if this a possibly 
issue in my case:

ARC enabled.
The warning "Capturing 'self' strongly in this block is likely to lead to a 
retain cycle" is issued in this method:

- (void) foo
{
    [self.operationQueue addOperationWithBlock:^{
        [self bar];
    }];
}

property operationQueue is declared 'strong'.


I understand the message, that is:

'self' is strongly retaining _operationQueue which itself strongly retains a 
block which itself strongly retains 'self'.


However, is this a problem in this case? I expect message bar to be queued in 
the operation queue. Meanwhile all references to 'self' diminish, except the 
one in the block. The block executes and eventually finishes and releases 
'self' - possibly the last reference.

Additionally, in this case, it is required that 'self' must not be destroyed 
prematurely - that is, before message bar finished.


Doesn't break the cycle automatically - and isn't this warning over-alert?


Thanks for clarification!





_______________________________________________

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