diff --git a/ChangeLog b/ChangeLog index ba6380c4d..f63ffec88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-10-17 Fred Kiefer + + * Source/NSString.m (-initWithCoder:): In keyed coding the key + "NS.bytes" may contain either an NSData or an NSString object. Not + sure about the encoding, I am using UTF8. + 2011-10-17 Richard Frith-Macdonald * standalone.conf: First draft at a layout for standalone system @@ -16,7 +22,7 @@ 2011-10-15 Gregory Casamento - * Documentation/GNUmakefile: + * Documentation/GNUmakefile: * Documentation/README.initialize: Documentation referred to by NSThread warning. diff --git a/Source/NSString.m b/Source/NSString.m index e6ede0442..e344dbfe7 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -5036,20 +5036,34 @@ static NSFileManager *fm = nil; { if ([aCoder allowsKeyedCoding]) { - NSString *string = nil; - if ([aCoder containsValueForKey: @"NS.string"]) - { - string = (NSString*)[(NSKeyedUnarchiver*)aCoder - _decodePropertyListForKey: @"NS.string"]; - } + { + NSString *string = nil; + + string = (NSString*)[(NSKeyedUnarchiver*)aCoder + _decodePropertyListForKey: @"NS.string"]; + self = [self initWithString: string]; + } else if ([aCoder containsValueForKey: @"NS.bytes"]) { - string = (NSString*)[(NSKeyedUnarchiver*)aCoder - decodeObjectForKey: @"NS.bytes"]; - } + id bytes = [(NSKeyedUnarchiver*)aCoder + decodeObjectForKey: @"NS.bytes"]; - self = [self initWithString: string]; + if ([bytes isKindOfClass: NSStringClass]) + { + self = [self initWithString: (NSString*)bytes]; + } + else + { + self = [self initWithData: (NSData*)bytes + encoding: NSUTF8StringEncoding]; + } + } + else + { + // empty string + self = [self initWithString: @""]; + } } else {