首页 > 代码库 > IOS应用发布NSLog的如何注释
IOS应用发布NSLog的如何注释
1 选择工程的Target -> Build Settings -> Preprocessor Macros.
如图,默认 Debug项,是“DEBUG=1”.
2 在程序中设置全局宏定义
在程序的 ApplicationName-Prefix.pch 文件中,加入如下,很简单
1 2 3 4 5 | #ifdef DEBUG #define DLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] ) #else #define DLog( s, ... ) #endif |
3 这样就设置好了,测试
在任意ViewController.m中写入
DLog(@ "1234" ); |
结果:
2012-07-25 17:09:54.448 xxxx[7094:707] <0x28f790 ViewController.m:(64)> 1234 |
这样发布的时候DLog就不会有输出了。
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。