问题
仅当我的测试为"is"时,我才会触发警告。这可能吗?我现在所拥有的不起作用。我该怎么办?
BOOL const TESTING = NO;
#if TESTING == YES
#warning don't forget to turn testing to NO before upload
#endif
答案
根据下面的答案,以下是对我有用的方法:
#define _TESTING // COMMENT THIS OUT TO DISABLE TESTING MODE
#ifdef _TESTING
BOOL const TESTING = YES;
#warning don't forget to turn testing to NO for production
#else
BOOL const TESTING = NO;
#endif
最佳答案
尝试用
替换您拥有的内容#ifdef TESTING
#warning //... warning here
BOOL const testingBool = YES;
#else
BOOL const testingBool = NO;
#endif
然后,您需要在目标的build设置中将 TESTING 添加为“预处理器宏”(有关如何执行此操作的更多详细信息,请参阅 this 问题)。
关于objective-c - 常量的条件编译警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14899628/