Ste*_*eve 6 memory iphone nslog ios
作为一个新的程序员,我发现了NSlog它的魔力,并通过我的代码使用它.它NSZombieEnabled在调试中非常有用(同时).
我可以在模拟器上看到明确的性能打击,因为它打印出所有这些东西.我不认为我在设备上看到任何这样的打击,但我不确定.
所以留下所有东西需要花费多少钱NSLogs?是否在设备上使用更多内存?或者编译器是否只是忽略它们,就像我为设备编译时的注释一样?
编辑:
根据我的建议,这是我实施的内容 rano.
在我的App_Prefix.pch文件中,我补充说:
// DLog is almost a drop-in replacement for NSLog
// DLog();
// DLog(@"here");
// DLog(@"value: %d", x);
// Unfortunately this doesn't work DLog(aStringVariable); you have to do this instead DLog(@"%@", aStringVariable);
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
// ALog always displays output regardless of the DEBUG setting
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
Run Code Online (Sandbox Code Playgroud)
然后在我的Project Info检查器中,对于Debug配置,在标题下GCC 4.2 - Preprocessing,我将值添加DEBUG到顶部条目中,Preprocessor Macros.
像魅力一样工作 - DLog当我构建Debug版本并ALog始终输出时输出.
| 归档时间: |
|
| 查看次数: |
1321 次 |
| 最近记录: |