Using @weakify
and @strongify
from libExtObjC helps to simplify the "weak-strong dance" one has to do sometimes around blocks.
Example!
__weak __typeof(self) weakSelf = self;
__weak __typeof(delegate) weakDelegate = delegate;
__weak __typeof(field) weakField = field;
__weak __typeof(viewController) weakViewController = viewController;
[viewController respondToSelector:@selector(buttonPressed:) usingBlock:^(id receiver){
__strong __typeof(weakSelf) strongSelf = weakSelf;
__strong __typeof(weakDelegate) strongDelegate = weakDelegate;
__strong __typeof(weakField) strongField = weakField;
__strong __typeof(weakViewController) strongViewController = weakViewController;
versus...
@weakify(self, delegate, field, viewController);
[viewController respondToSelector:@selector(buttonPressed:) usingBlock:^(id receiver){
@strongify(self, delegate, field, viewController);