If my block does not capture variables, I get __NSGlobalBlock__.
Class class = [^{
} class];
NSLog(@"%@", NSStringFromClass(class));
But if I grab the variables, I get __NSStackBlock__
int foo = 3;
Class class = [^{
int foo1 = foo;
} class];
NSLog(@"%@", NSStringFromClass(class));
Why is a block in global memory needed? What is the advantage __NSGlobalBlock__vs __NSStackBlock__?
I read the Block Implementation Specification , but I don’t understand why I need __NSGlobalBlock__it if I create the block for one use only.
source
share