NSLog and print object

I have a class and I want to customize what is printed when I call NSLog with this class. For example,

NSLog (@ "% @", nonstandardObject);

How do I set up an object to print what I need?

+6
objective-c
source share
1 answer

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

Another option, called -debugDescription (returns an NSString , with no parameters), which is used when positioning an object from gdb.

+14
source share

All Articles