Good day.
In my "universal" code (for both 10.5 and 10.6 + 10.7), I usually use this structure:

+ (id)some_method { #if NS_BLOCKS_AVAILABLE __block id some_var; /* Операции с блоками */ #else id some_var; /* Аналогичный код, но без блоков */ #endif } 

That is, in essence, duplicate declarations of all variables. I don’t like this method, because there is a bunch of duplicate code.

Therefore, the question is: what if you initialize variables only once (regardless of whether it supports runtime blocks or not) with the identifier __block? How will systems where blocks are not supported (<10.6, <iOS4.0) react to it? In fact, they should curse at him wildly, but who knows.

PS I would check it myself, but not a single car with 10.5 is at hand.

    1 answer 1

    And why not so:

     + (id)some_method { #if NS_BLOCKS_AVAILABLE __block #endif id some_var; } 

    Or so:

     #if NS_BLOCKS_AVAILABLE #else #define __block #endif 
    • @timka_s well, for sure, you can zadefaynit it! Thank you, it is strange that it did not occur to me. Convert back, please. - VioLet