I am curious how I might override the description method that is used when you do the following (see below) for an object. I basically want to better format the output, but am unsure about how I might go about setting this up.
NSLog(@"ARRAY: %@", myArray);
many thanks
EDIT_001
Although subclassing NSArray would have worked I instead decided that I would add a category to NSArray (having not used one before) Here is what I added ...
// ------------------------------------------------------------------- **
// CATAGORY: NSArray
// ------------------------------------------------------------------- **
@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