I am curious how I can override the description method that is used when you do the following (see below) for an object. I basically want to format the output better, but I'm not sure how I can configure this.
NSLog(@"ARRAY: %@", myArray);
many thanks
EDIT_001
Although a subclass of NSArray would work, I decided that I would add a category to NSArray (not using it before) Here's what I added ...
@interface NSArray (displayNSArray)
-(NSString*)display;
@end
@implementation NSArray (displayNSArray)
-(NSString*)display {
id eachIndex;
NSMutableString *outString = [[[NSMutableString alloc] init] autorelease];
[outString appendString:@"("];
for(eachIndex in self) {
[outString appendString:[eachIndex description]];
[outString appendString:@" "];
}
[outString insertString:@")" atIndex:[outString length]-1];
return(outString);
}
@end
Gary
source
share