Can someone confirm if the block below is turning into a retain cycle please? Please note the block is being called by SampleClass2 not SampleClass1.
@interface SampleClass1{
NSArray *_array;
}
@implementation SampleClass1
-(void) doSomething {
SampleClass2 *sampleClass2 = [[SampleClass2 alloc] init];
[sampleClass2 doAnother:^(NSArray *anotherArray){
_array = anotherArray; // _array is an ivar
}];
}
@end
self
? Yes.sampleClass2
retain the block? Maybe. It depends on what thedoAnother:
method does. Without the code, it's impossible to say.sampleClass2
retains the block, is there a retain cycle? No. There is a connectionsampleClass2 -> the block -> self
, but nowhere from the code shown is there a connection fromself
tosampleClass2
.