I'd like to override the default print function in NSLog for custom objects;
For example:
MyObject *myObject = [[MyObject alloc] init];
NSLog(@"This is my object: %@", myObjcet);
Will print out:
This is my object: <MyObject: 0x4324234>
Is there a function I override in MyObject to print out a prettier description?
Cheers! Nick.
Just implement the description
method.
- (NSString *)description {
return @"MyCustomDescription";
}
This is the method used to print an instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With