|
From: | Wolfgang Lux |
Subject: | Re: Logging NSData |
Date: | Fri, 22 Jul 2011 10:51:35 +0200 |
Hi Andreas,
Hi Richard,I am logging out NSDictionaries that sometimes contain NSData instances as values. On MacOSX NSData::description is called to determine a string that is used in the output. I don't want to see tons of hex values for large NSData objects in the output and therefore wrote the following category:@implementation NSData (SRDataExtension) - (NSString *)description {return [NSString stringWithFormat:@"<data of length %d>", [self length]];} @endThis works great on MacOSX but not under GNUstep. It seems that description is not called under GNUstep when a dictionary is logged out withNSLog(@"dic %@", dic); Any idea?GNUstep uses -descriptionWithLocale: Perhaps we should change that if it's no longer used in OSX?I have implemented - (NSString *)descriptionWithLocale:(id)locale {return [NSString stringWithFormat:@"<data of length %d>", [self length]];}no in my category, but this method isn't used either by NSLog(@"dic %@", dic)!? :-(I checked core/base/Source/NSData.m but it has no implementation for descriptionWithLocale: either!?
AFAIU, your problem appears to be the implementation of NSDictionary's -description method (or really - descriptionWithLocale:indent:). This method is implemented by converting the dictionary into a (old-style) property list and that code converts NSData instances without invoking their -description (or -descriptionWithLocale:) methods (for the obvious reason). So I guess, you'll have to override NSDictionary -description for now as well.
Wolfgang
[Prev in Thread] | Current Thread | [Next in Thread] |