There are two functions that you can use.
- (NSString*)description
This will be displayed when you put your object as, I.E. a parameter for NSLog
. The other description function is:
- (NSString*)debugDescription
This will be called when you do po anInstanceOfYourClass
in the debug command window. If your class doesn't have a debugDescription
function, then just description
will be called.
Note that the base class NSObject
does have description
implemented, but it is fairly bare-bones: it only displays the address of the object. This is why I recommend that you implement description
in any class you want to get info out of, especially if you use the description
method in your code. If you do use description
in your code, I suggest you implement debugDescription
as well, also making debugDescription
more verbose.
description
property is reserved ...and will provide useful debugging information! In that case you'll need to come up with your own unique method name. – Klemens