开发者

Do I have alternatives to using NSLog to debug object values?

Is NSLog the best way to debug the value of variables during execution? I find that navigating into the obj开发者_运维问答ect 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?


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


There's a debugger, too.


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__]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜