[IPhone] 仅在Debug编译的NSLog

来源:互联网 发布:mmd镜头数据如何导入 编辑:程序博客网 时间:2024/05/22 08:18

一般在开发的时候,会使用NSLog来输出一些除错讯息到Console视窗
但是如果仅用NSLog的话
首先利用下面代码

  1. #ifdef DEBUG  
  2. #define DebugLog(log, ...) NSLog(log, ## __VA_ARGS__)  
  3. #undef DebugLog  
  4. #define DebugLog(log) NSLog(log)  
  5. #else  
  6. #define DebugLog(log, ...)  
  7. #undef DebugLog  
  8. #define DebugLog(log) NSLog(log)  
  9. #endif  
在Xcode的Project=>Edit Active Target "MyProject" 开启编辑画面
GCC_PREPROCESSOR_DEFINITIONS中加入DEBUG
 如果没有GCC_PREPROCESSOR_DEFINITIONS则自行建立

原创粉丝点击