Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable NSLog?

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 calls. Is this possible? Is there an easy way to do this?

like image 882
CodeGuy Avatar asked Jul 18 '11 11:07

CodeGuy


3 Answers

wait there is far more simple method. Just add the following lines when you dont need NSLOG to your constants file

#define NSLog                       //

and comment it when you need it.

EDIT: In latest Xcode, you get error on above statement. So I figured out the best way is

#define NSLog(...) 
like image 59
Saqib Saud Avatar answered Sep 28 '22 18:09

Saqib Saud


Update:

The answer bellow is actually much better. See here.

Initial answer:

There is a little hack that you could do. Search for all NSLog and replace them with //NSLog and than do another search for ////NSLog and replace them with //NSLog.

like image 42
Mihai Fratu Avatar answered Sep 28 '22 19:09

Mihai Fratu


#define NSLog if(1) NSLog

if you dont want log set 1 as 0.

like image 30
Prateek Prem Avatar answered Sep 28 '22 20:09

Prateek Prem