I have NSLogs in code, so many time. A easy solution is that I replace with
NSLog(@ with //NSLog(@
But, If I want to remove all the lines, starting with NSLog, what can I do?
Thanks
I have NSLogs in code, so many time. A easy solution is that I replace with
NSLog(@ with //NSLog(@
But, If I want to remove all the lines, starting with NSLog, what can I do?
Thanks
If your NSLogs are written in a single line, you can do a regex search and replace. Enter NSLog.*$
as the search regex and replace it with an empty string. All your NSLog statements should disappear.
In Xcode just search and replace from the Project Navigator. You can select "Starting with", "Contains", "Regular Expression", etc.
Using Regular Expression ^[\s\W]+NSLog.*$
should work well for lines that might have a tab or space before the NSLog
but won't catch lines with other text that may be in front of it. (notice in the second screen shot NSLog
was detected at the end of the line, while the first didn't).
Another example might be if you want to keep commented NSLog
lines and remove the others:
^[^/*]*[\s\t]*NSLog.*$
Would remove NSLog
on line 3 and NSLog(@"%@",removed);
on line 7.
// NSLog
/* NSLog */
NSLog
NSString *NSLog = @"not nslog"
NSLog(@"%@",removed);
Additional Examples:
Add the following lines to your ConvenienceMethods file:
#define SHOWLOGS NO
#defile NSLog if(SHOWLOGS)NSLog
If you don't have ConvenienceMethods file just write it on your controllers.