The Sudzc generated code is over writing a dictionary for deserialized nodes. If I use the NSLog(@\"The Child Node: %@\", [[[element children] objectAtIndex:0] stringValue]
as soon as I get enough rep points I will, but I did notice that the code begins and ends with
[d setObject:v forKey:[child name]];
and for me I had to remove the initial line, and that fixed it for me, so the code looks like this:
// Deserializes the element in a dictionary.
+(id)deserializeAsDictionary:(CXMLNode*)element {
if([element childCount] == 1) {
CXMLNode* child = [[element children] objectAtIndex:0];
if([child kind] == CXMLTextKind) {
return [[[element children] objectAtIndex:0] stringValue];
}
}
NSMutableDictionary* d = [NSMutableDictionary dictionary];
for(CXMLNode* child in [element children]) {
id v = [Soap deserialize:child];
if(v == nil) { v = [NSNull null]; }
//[d setObject:v forKey:[child name]]; //seems to be duped (maybe my bad)
//Extended by iDev on StackOverflow
//http://stackoverflow.com/questions/10235496/sudzc-deserializeasdictionary-over-written-dictionary/10358458#10358458
NSString* key = [child name];
id check = [d objectForKey:key];
if( check != nil ) {
NSInteger next = 1;
key = [NSString stringWithFormat:@"%@%04d", [child name], next];
check = [d objectForKey:key];
while( check != nil ) {
next++;
key = [NSString stringWithFormat:@"%@%04d", [child name], next];
check = [d objectForKey:key];
}
[d setObject:v forKey:key];
}
[d setObject:v forKey:[child name]];
//End Extension
}
return d;
}