* 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.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34010 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2011-10-17 08:28:38 +00:00
parent a6a481bead
commit e6a75007c0
2 changed files with 31 additions and 11 deletions

View file

@ -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
{