如何在整个应用程序中禁用NSLog? [英] How to disable NSLog all over the app?

查看:160
本文介绍了如何在整个应用程序中禁用NSLog?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用中的所有实例中禁用 NSLog()。我找到了一些代码:

I want to disable NSLog() across all instances in an app. I found some code that does that:

#ifndef DEBUG
#define NSLog //
#endif

但是将此代码添加到每个文件并不是一个好主意。如何让它更容易?

But adding this code to each file isn't good idea. How can I make it easier?

推荐答案

Xcode有一个预编译的头文件( {project-name}默认情况下,在Supporting Files组中的-prefix.pch ,这是放置将在项目中的每个文件中使用的代码的好地方。要更进一步并改进日志消息本身,请参阅是否应该在生产代码上使用NSLog()?

Xcode has a precompiled header file ({project-name}-Prefix.pch in the Supporting Files group by default) that is a great place to put code that will be used across every file in the project. For going a step further and improving the log message itself, see Is it true that one should not use NSLog() on production code?.

这篇关于如何在整个应用程序中禁用NSLog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆