I am just about to submit my first iPhone app.
I have put lots of NSLog statements to test and debug the application .
So my question is " Is it ok to keep the NSLog statements in the source code "
and I have a doubt that whether the nslog statements slows down the total execution time or not .
thanks.
I used this all the time (found it somewhere):
// 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__)
The three20 project from Facebook has more complex way to debug or logging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With