Sun*_*day 6 static const objective-c c-preprocessor
可能重复:C中的
"static const"vs"#define"
在Objective-C中,以下两行之间有什么区别:
#define myInteger 5
static const NSInteger myInteger = 5;
Run Code Online (Sandbox Code Playgroud)
假设它们位于实现指令之上的MyClass.m中.
Dru*_*erB 15
#define myInteger 5
Run Code Online (Sandbox Code Playgroud)
是一个预处理器宏.预处理器将取代的每一次出现myInteger与5编译器IST开始前.它不是一个变量,它只是一种自动查找和替换机制.
static const NSInteger myInteger = 5;
Run Code Online (Sandbox Code Playgroud)
这是一个常量的"实际"变量(声明后不能更改).静态意味着它将是对该块的多次调用的共享变量.
| 归档时间: |
|
| 查看次数: |
10659 次 |
| 最近记录: |