创建头文件(.h), 导出常量:
// Constants.h
FOUNDATION_EXPORT NSString *const MyFirstConstant;
FOUNDATION_EXPORT NSString *const MySecondConstant;
//etc.
(代码不用于C/C++混合编程时, 能够使用extern取代FOUNDATION_EXPORT.)
定义源文件(.m), 设置常量:
// Constants.m
NSString *const MyFirstConstant = @"FirstConstant";
NSString *const MySecondConstant = @"SecondConstant";
//etc.
使用类常量时, 须要引入头文件(.h).