compatibility fix for macos-x

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19514 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-06-14 05:27:54 +00:00
parent 59fb483aec
commit 6b1d2c2047
2 changed files with 32 additions and 30 deletions

View file

@ -1,3 +1,8 @@
2004-06-14 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSDictionary.m: MacOS-X compatibility fix for keyed encoding
of empty dictionary.
2004-06-10 Adam Fedor <fedor@gnu.org>
* Version 1.9.2

View file

@ -182,41 +182,38 @@ static SEL appSel;
if ([aCoder allowsKeyedCoding])
{
if (count > 0)
id key;
unsigned i;
if ([aCoder class] == [NSKeyedArchiver class])
{
NSArray *keys = [self allKeys];
id objects = [NSMutableArray arrayWithCapacity: count];
for (i = 0; i < count; i++)
{
key = [keys objectAtIndex: i];
[objects addObject: [self objectForKey: key]];
}
[(NSKeyedArchiver*)aCoder _encodeArrayOfObjects: keys
forKey: @"NS.keys"];
[(NSKeyedArchiver*)aCoder _encodeArrayOfObjects: objects
forKey: @"NS.objects"];
}
else if (count > 0)
{
NSEnumerator *enumerator = [self keyEnumerator];
id key;
if ([aCoder class] == [NSKeyedArchiver class])
i = 0;
while ((key = [enumerator nextObject]) != nil)
{
NSArray *keys = [self allKeys];
id objects = [NSMutableArray arrayWithCapacity: count];
unsigned i;
NSString *s;
for (i = 0; i < count; i++)
{
key = [keys objectAtIndex: i];
[objects addObject: [self objectForKey: key]];
}
[(NSKeyedArchiver*)aCoder _encodeArrayOfObjects: keys
forKey: @"NS.keys"];
[(NSKeyedArchiver*)aCoder _encodeArrayOfObjects: objects
forKey: @"NS.objects"];
}
else
{
unsigned i = 0;
while ((key = [enumerator nextObject]) != nil)
{
NSString *s;
s = [NSString stringWithFormat: @"NS.key.%u", i];
[aCoder encodeObject: key forKey: s];
s = [NSString stringWithFormat: @"NS.object.%u", i];
[aCoder encodeObject: [self objectForKey: key] forKey: s];
i++;
}
s = [NSString stringWithFormat: @"NS.key.%u", i];
[aCoder encodeObject: key forKey: s];
s = [NSString stringWithFormat: @"NS.object.%u", i];
[aCoder encodeObject: [self objectForKey: key] forKey: s];
i++;
}
}
}