I was googling a method to hide my NSLog statements from my release version and found this thread
Where in a comment is mentioned…
defaults write my.bundle.identifier SandboxModeFlag -bool YES
This sounds great, it doesn’t rely on me forgetting to remove my own flag saying I’m in debug mode.
Can anyone tell me how to detect SandModeFlag in code?
That command line sets NSUserDefaults, so it could be read with:
[[[NSUserDefaults] standardUserDefaults] boolForKey:@"SandboxModeFlag"]Here’s a link to the Apple documentation.
Edit
To elaborate, that gives you the ability to turn the logging on and off without using a different build. Of course, checking this at runtime is an overhead that may be undesirable.
If using a different build is acceptable, then macros are the way forward. Here’s a post describing your situation, with some nice examples.