How do I disable NSLog?

前端 未结 15 2125
陌清茗
陌清茗 2020-12-05 07:46

I\'d like to do the following in Xcode:

Find all NSLog commands without comments, and replace it with //NSLog...

In other words, I want to comment all NSLog

15条回答
  •  长情又很酷
    2020-12-05 08:35

    The answers you have are correct for your question. But. Your real question is how to turn of NSLogs in certain conditions. i.e. you want them to show for Debug builds, and not for Release builds. In which case try defining and using the DLog() macro as described on Cocoa Is My Girlfriend. If you're using Xcode4 it's even easier because the Debug and Release builds define and undefine DEBUG so you don't have to do that.

    It's a lot easier than commenting and uncommenting lines of code.

提交回复
热议问题