ivar is inside two blocks
- by Desperate Developer
I have an ivar like this declared on interface:
BOOL controllerOK;
I have to use this ivar inside a block that resides itself in a block. Something like
myBlockl = ^(){
[self presentViewController:controller
animated:YES
completion:^(){
if (controllerOK)
[self doStuff];
}];
};
If I try to do that, I see an error capturing self strongly in this block is likely to lead to a retain cycle for the if (controllerOK) line.
This does not appear to be one of those blocks problems that you create another variable using __unsafe_unretained before the block starts. First because this instruction cannot be used with a BOOL and second because the ivar controllerOK has to be tested on runtime inside the block. Another problem is that the block itself is declared on the interface, so it will be used outside the context where it is being created.
How do I solve that?