Preprocessor in Xcode
I want to set the DEBUG
value to 1 or 0 from code. After specific event answer and not from
other C Flags?
#if DEBUG==1
#define DBLog(format, ...) NSLog(@"%s:%@", __PRETTY_开发者_运维技巧FUNCTION__,[NSString stringWithFormat:format, ## __VA_ARGS__]);
#define MARK DBLog(@"%s", __PRETTY_FUNCTION__);
#else
#define DBLog(format, ...)
#define MARK
#endif
The preprocessor directives are used in a phase before compiling your code, so you can't choose one of those branches during execution. You have to use a static variable or something like that.
if (mystaticvariable) { DBLog...
精彩评论