Ho usato tutto il tempo (che si trova da qualche parte):
// DLog is almost a drop-in replacement for NSLog to turn off logging for release build
//
// add -DDEBUG to OTHER_CFLAGS in the build user defined settings
//
// Usage:
//
// DLog();
// DLog(@"here");
// DLog(@"value: %d", x);
// Unfortunately this doesn't work DLog(aStringVariable); you have to do this instead DLog(@"%@", aStringVariable);
//
#ifdef DEBUG
# define DLog(__FORMAT__, ...) NSLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
# define DLog(...) do {} while (0)
#endif
// ALog always displays output regardless of the DEBUG setting
#define ALog(__FORMAT__, ...) NSLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
Il progetto Three20 da Facebook ha modo più complesso per eseguire il debug o la registrazione.
fonte
2010-02-05 19:06:04
Vedere http://stackoverflow.com/questions/300673/is-it-true-that-one-should-not-use-nslog-on-production-code – Vladimir