In this question, I asked about the following code and saved the loops:
__weak Cell *weakSelf = self;
NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock:^{
UIImage *image =
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[weakSelf setImageViewImage:image];
}];
}];
[self.renderQueue addOperation:op];
All answers state that using a weak link was not necessary here, as this code does not lead to a save loop. However, experimenting with some other code, the following leads to a save loop (unless I use a weak link, the current view controller is not freed)
MBItem *close = [[MBItem alloc] initWithBlock:^{
[self dismissModalWithDefaultAnimation:NO];
}];
NSMutableArray *items = [[NSMutableArray alloc] initWithObjects:close, nil];
[self.childObject setItems:items];
Why does the second result lead to a save cycle, but not to the first?
source
share