2010年6月19日 星期六

[IPhone] only at debug mode using NSLog

When develop iphone program, we using NSLog to trace our code or do some debug.
But NSLog will build at release mode.
So we can use these code to do it.

#ifdef DEBUG
#define debug_NSLog(format, ...) NSLog(format, ## __VA_ARGS__)
#else
#define debug_NSLog(format, ...)
#endif

Then we need to edit Xcode setting, click Project => Edit Active Target "MyProject" to open dialog.
Edit GCC_PREPROCESSOR_DEFINITIONS item and add DEBUG keyword.

沒有留言:

張貼留言

Hello