我正在为我的应用外部化一些常量,并决定使用外部文件 Constants.h。
这是正确的做法吗?我在程序错误中收到“意外的‘@’。应该将#defines 放在这个头文件中的什么位置?
//
// Constants.h
@interface Constants : NSObject {
}
#define height 227
#define width 40
@end
最佳答案
在您的 Constant.h 文件中,仅像这样定义 Constant:
#define height 227
#define width 40
并将这个 Constant 文件导入到您的 Prefix.pch 文件中
#ifdef __OBJC__
#import "Constant.h"
#endif
关于objective-c - 在 Objective-C 中使用常量的正确方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9749988/