mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
More keyed coding updates.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18495 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
43eff241a0
commit
412c677079
11 changed files with 326 additions and 118 deletions
|
@ -104,20 +104,27 @@ static SEL objSel;
|
|||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
unsigned count = map.nodeCount;
|
||||
SEL sel = @selector(encodeObject:);
|
||||
IMP imp = [aCoder methodForSelector: sel];
|
||||
GSIMapEnumerator_t enumerator = GSIMapEnumeratorForMap(&map);
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
|
||||
while (node != 0)
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
(*imp)(aCoder, sel, node->key.obj);
|
||||
(*imp)(aCoder, sel, node->value.obj);
|
||||
node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
self = [super initWithCoder: aCoder];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned count = map.nodeCount;
|
||||
SEL sel = @selector(encodeObject:);
|
||||
IMP imp = [aCoder methodForSelector: sel];
|
||||
GSIMapEnumerator_t enumerator = GSIMapEnumeratorForMap(&map);
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
|
||||
while (node != 0)
|
||||
{
|
||||
(*imp)(aCoder, sel, node->key.obj);
|
||||
(*imp)(aCoder, sel, node->value.obj);
|
||||
node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
}
|
||||
GSIMapEndEnumerator(&enumerator);
|
||||
}
|
||||
GSIMapEndEnumerator(&enumerator);
|
||||
}
|
||||
|
||||
- (unsigned) hash
|
||||
|
@ -129,12 +136,7 @@ static SEL objSel;
|
|||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *keys = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.keys"];
|
||||
NSArray *objects = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.objects"];
|
||||
|
||||
self = [self initWithObjects: objects forKeys: keys];
|
||||
self = [super initWithCoder: aCoder];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue