ios - 声明 __block 变量的正确方法是什么?

标签 ios objective-c variables syntax

我应该声明为

(#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/

相关文章:

ios - 如何让CAKeyframeAnimation在动画期间与用户交互?

iphone - 是否可以使用 GNUstep 将 iOS 应用程序移植到 Windows? (用于学习目的)

ios - 已弃用的应用程序 :openURL method - iOS

objective-c - 给定进程 ID,确定进程是否是 Mac 上的窗口进程

java - 声明一堆相似变量的最少行数

ios - 快速隐藏/显示基于文本的文本字段和按钮

ios - 如何从 AFNetworking ios 中的 block 中提取数据?

ios - 将 NSUrl 转换为 PHAsset iOS 8

flash - Youtube API 函数

linux - 两次 Bash 命令替换