I been having a bit of a discussion in regards to weakify and strongify. I understand that you need to first weakify and then strongify for a block if there is a retain cycle.
i.e self(view controller) owns a label which owns a block (strong ref) and inside the block callback the there is a reference to self . I understand that they all link to each other strongly hence the retain cycle.
However, should the below have a weakify and strongify as I don't see any retain cycle since the declaration of phoneviewcontroller is local. Been quite confused with this. Please note that view controller has an @property copy to the setfinishblock.
- (void) doSomething{
PhoneViewController *viewController = [[PhoneViewController alloc] initWithNibName:@"xxxxx" bundle:nil];
@weakify(self)
[viewController setFinishBlock:^(UIImage *image) {
@strongify(self)
[Sharedmanager dosomethign:something];
}];
}
Thanks.