我应该声明为
(#1) 类名 * __ block 变量名
或
(#2) __block 类名 * 变量名
?
我看到很多代码使用格式 #2,包括 Apple 的 Blocks Programming Topics .
但最近我发现Apple的“Transitioning to ARC Release Notes”说:
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/.
所以我很困惑,我以后应该使用哪种格式?
最佳答案
它们本质上是一样的。我个人更喜欢将 __block
放在开头,因为它比变量的类型更重要。
关于ios - 声明 __block 变量的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23539286/