开发者

NSLog and printing of an object

开发者 https://www.devze.com 2022-12-09 06:51 出处:网络
I have a class and I want to setup wha开发者_如何学运维t is printed when I call NSLog with that class. For example,

I have a class and I want to setup wha开发者_如何学运维t is printed when I call NSLog with that class. For example,

NSLog(@"%@",nonstandardObject);

How do I setup the object so it prints out what I'd want?


Override the -description method. It takes no parameters and returns an NSString that get's printf'd out.

There's another variant called -debugDescription (returns NSString, no parameters) that's used when po'ing the object from gdb.

0

精彩评论

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