user603592
user603592

Reputation: 71

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 

Upvotes: 2

Views: 394

Answers (1)

Jano
Jano

Reputation: 63667

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

Upvotes: 1

Related Questions