Objective-C - 类的静态常量

来源:互联网 发布:mac商店英文改中文版 编辑:程序博客网 时间:2024/05/01 04:15

创建头文件(.h), 导出常量:

// Constants.hFOUNDATION_EXPORT NSString *const MyFirstConstant;FOUNDATION_EXPORT NSString *const MySecondConstant;//etc.

(代码不用于C/C++混合编程时, 可以使用extern代替FOUNDATION_EXPORT.)

定义源文件(.m), 设置常量:

// Constants.mNSString *const MyFirstConstant = @"FirstConstant";NSString *const MySecondConstant = @"SecondConstant";//etc.

使用类常量时, 需要引入头文件(.h).


娱乐

2 0
原创粉丝点击