Why is the __block keyword allowed in the interface?

If I try to access the "object variable" with the storage type __block:

@interface { __block float x; } 

in the block:

 @implementation ... { ... -(void) func: { ^(...) { x = 0; } } 

I get a โ€œsave loopโ€ warning if I donโ€™t create the __block link for myself and use it like:

 -(void) func: { __block id s = self; ^(...) { s->x = 0; } } 

Why can I declare a variable "__block" in the interface?

+6
source share
1 answer

__ Block variables live in a repository that is shared between the lexical region of the variable and all blocks and block copies declared or created within the lexical region of the variables. cm.

0
source

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


All Articles