Sudzc deserializeAsDictionary: over written dictionary

后端 未结 5 987
渐次进展
渐次进展 2021-01-17 08:06

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]

5条回答
  •  失恋的感觉
    2021-01-17 09:06

    I was having issues with the above code - it was overwriting the first entry each time - ie I would get a list of 4 items and the first and fourth would be duplicated.

    After a lot of exhausting stepping thru code (love recursive code NOT), I found what I believe was the issue;

    My code is as follows:

        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];  
        }
        else
        {
              [d setObject:v forKey:[child name]];
        }
    

提交回复
热议问题