Pergunta

Should I declare it as

(#1) ClassName * __block variableName

or

(#2) __block ClassName * variableName

?

I seen a lot of code uses format #2, Including Apple's Blocks Programming Topics.

But recently I found Apple's "Transitioning to ARC Release Notes" says:

You should decorate variables correctly. When using qualifiers in an object variable declaration, the correct format is:

ClassName * qualifier variableName;

for example:

MyClass * __weak myWeakReference;

Other variants are technically incorrect but are “forgiven” by the compiler. To understand the issue, see http://cdecl.org/.

So I'm confused, Which format should I use in the future?

Foi útil?

Solução

They are essentially the same. I personally prefer placing __block at the beginning since it's more important than the variable's type.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top