问题
只有当我的 TESTING 为 YES 时,我才想触发警告。这可能吗?我现在所拥有的不起作用。我该怎么办?
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