1

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?

TheLearner
  • 19,387
  • 35
  • 95
  • 163

3 Answers3

1

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
Community
  • 1
  • 1
Jordan
  • 21,746
  • 10
  • 51
  • 63
1

There's a debugger, too.

0

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
  • 4,539
  • 1
  • 19
  • 20