If one def开发者_JAVA技巧ines a block within a block within a function,
what scope does the inner block have access to.
Also, would you have to do this to prevent retaining of self
(pretend blocks are formed properly):
-(void)function
{
__block id me = self;
^{
__block id me2 = me;
^{
[me2 ...];
^}
^}
}
I have blocks of the form
-(void) function
{
__block bool isOK = true;
// ...
[someArray enumerateObjectsWithBlock: ^(id obj, bool** stop)
{
// ...
[someOtherArray enumerateObjectsWithBlock: ^(id obj, bool** stop)
{
// ...
isOK = false;
}];
}];
}
So the inner block has access to the scope of the outer block.
Why do you want to prevent self from being retained? The object has to sty around for the lifetime of the blocks anyway.
精彩评论