ivar is inside two blocks
Posted
by
Desperate Developer
on Stack Overflow
See other posts from Stack Overflow
or by Desperate Developer
Published on 2012-11-26T04:33:42Z
Indexed on
2012/11/26
5:03 UTC
Read the original article
Hit count: 214
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?
© Stack Overflow or respective owner