views:

57

answers:

3

Is NSLog the best way to debug the value of variables during execution? I find that navigating into the object doesn't show me what I want to see and I find I have to NSLog all over my application.

Is there something that I am missing?

+1  A: 

Try this

#ifdef DEBUG
#define DLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DLog( s, ... ) 
#endif
Jordan
+1  A: 

There's a debugger, too.

Graham Lee
A: 

Sorry, this didn't fit as a comment, couldn't format it.

I find that __PRETTY_FUNCTION__ does a nice job. It tells the class and method name.

#define PLog(fmt, ...) NSLog(@"%s L%d %@", \__PRETTY_FUNCTION__, \__LINE__, [NSString stringWithFormat:fmt, ##__VA_ARGS__]);
Daniel Blezek