Zig*_*rth 6 iphone performance nslog ipad
我想知道是否有许多NSLog()调用会影响应用程序性能或内存.有谁知道这件事吗?
我想在我的应用程序中的每个函数中放置一个NSLog()调用(这很多),以便我可以看到崩溃日志并跟踪问题.
谢谢.
Mug*_*nth 11
是.所以我在我的pch文件中定义了这个.
#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)
我没有使用NSLog,而是使用DLog和ALog.
(注意或版权:很久以前我从其他一些我不记得的帖子中获得了这段代码.再次从我的代码库中删除它)
"取消定义"NSLog的另一个简单解决方案
在.pch文件中:
#ifndef DEBUG
#define NSLog(...) /* */
#endif
Run Code Online (Sandbox Code Playgroud)