#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt),__PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
# define DLog(...)
#endif
Put that in your [Project]-Prefix.pch file to make it available globally. Aside from letting you log without fear, it gives you better performance in production, and you can get extra context for your output.
1: http://stackoverflow.com/questions/969130/how-to-print-out-t...
Besides causing incorrect output, this may crash your program, or potentially be a vector for an exploit.
"In particular, the varargs mechanism allows functions to accept any number of arguments (e.g. printf) by "popping" as many arguments off the call stack as they wish, trusting the early arguments to indicate how many additional arguments are to be popped, and of what types."
NSLog is similar; it has to trust its first argument to be consistent with the number and types of arguments actually passed to it.
If you call NSLog(x), but do not have complete control over the value of x, you cannot guarantee that.
NSLog(untrusted); bad. NSLog("The user entered %s", untrusted); OK.