一般在开发的时候,会使用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则自行建立
一般在开发的时候,会使用NSLog来输出一些除错讯息到Console视窗
但是如果仅用NSLog的话
在GCC_PREPROCESSOR_DEFINITIONS中加入DEBUG