开发者

Preprocessor in Xcode

开发者 https://www.devze.com 2023-02-28 17:56 出处:网络
I want to set the DEBUG value to 1 or 0 from code. After specific event answer and not from other C Flags?

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...
0

精彩评论

暂无评论...
验证码 换一张
取 消