我需要接受字符串键值对的 NSMutableDictionary 并且需要复制到 stl 映射。有没有简单的方法可以做到这一点?我试过这个,但这不起作用。
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[dictionary setObject:@"10" forKey:@"6"];
[dictionary setObject:@"10" forKey:@"7"];
[dictionary setObject:@"10" forKey:@"8"];
NSEnumerator *enumerator = [dictionary keyEnumerator];
NSString *key;
while ((key = [enumerator nextObject])) {
std::string *keyString = new std::string([key UTF8String]);
std::string *valueString = new std::string([[dictionary objectForKey:key] UTF8String]);
map[*keyString] = *valueString;
}