Sudzc deserializeAsDictionary: over written dictionary

后端 未结 5 1015
渐次进展
渐次进展 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 08:51

    I found that you have to put an else block in as well:

    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]];
    }
    //End Extension
    

    Otherwise elements in 'd' will be overwritten because setObject is called twice.

提交回复
热议问题