I'm currently thinking about how to prevent strong reference cycles when using blocks that retain self. The usual way seems to be to just use a weak reference to self:
@property (strong, nonatomic) NSOperationQueue *queue;
- (void)methodA {
__weak id *weakSelf = self;
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
[weakSelf methodB];
}];
[self.queue addOperation:operation];
}
But what if methodB looks like this:
- (void)methodB {
[self someOtherMethod];
}
Would this still cause a strong reference cycle? Or would methodB receive the weak reference to self from methodA as its reference to self? (That is, is methodB's reference to self just a strong reference to the weak reference from methodA?)
free
d is it, it'srelease
d (retain count--) so when the block terminates the object will be destroyed, so it'll probably be OK. – trojanfoe