[IPhone] 仅在Debug编译的NSLog

一般在开发的时候,会使用NSLog来输出一些除错讯息到Console视窗
但是如果仅用NSLog的话
首先利用下面代码
#ifdef DEBUG #define DebugLog(log, ...) NSLog(log, ## __VA_ARGS__) #undef DebugLog #define DebugLog(log) NSLog(log) #else #define DebugLog(log, ...) #undef DebugLog #define DebugLog(log) NSLog(log) #endif
在Xcode的Project=>Edit Active Target "MyProject" 开启编辑画面
GCC_PREPROCESSOR_DEFINITIONS中加入DEBUG
如果没有GCC_PREPROCESSOR_DEFINITIONS则自行建立
[IPhone] 仅在Debug编译的NSLog_第1张图片

你可能感兴趣的:(gcc,xcode,iPhone,preprocessor)