I am tying to generalize calling NSLog and avoid having to comment-out the calls when I am finished debugging.
I have:
#define USE_ADLog 0
#define USE_RPLog 0
#define USE_DLLog 1
void ConsoleADLog(NSString *message, ...);
void ConsoleRPLog(NSString *message, ...);
void ConsoleDLLog(NSString *message, ...);
and, for example:
void ConsoleADLog(NSString *message, ...) {
#if (USE_ADLog)
va_list optionalArgs;
va_start(optionalArgs, message); // after the parm = message
va_end(optionalArgs);
NSLog(message, optionalArgs);
#endif
}
So far, so good ... however, as soon as I call, for example,:
ConsoleDLLog(@"parm1 = %@, parm2 = %@", parm1, parm2);
which call is inside a secondary thread, I bomb. I thought?? that va_start, va_end were thread safe.
... or is the problem %@ ... I know %f works ???
Apparently not!, so how do I make them thread safe ... plain ole
NSLog(@"whatever %@", whateverParm)
works, but not the function above.
Thanks,