Objective-C why __NSGlobalBlock__ is needed

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.

+4
source share
1 answer

Global Stack , . Global, , . , copy, -op. Stack, , , , . ARC.

+1

Source: https://habr.com/ru/post/1617845/


All Articles