문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top