我需要从2 NSMutableDictionary添加值这里是我的例子但不工作=(
NSMutableDictionary *coord = [[NSMutableDictionary alloc] init];
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
data = [dao obtenerDatosFinales];
你需要得到两个值objectForKey并填充另一个NSMutableDictionary(coord)
coord = [data objectForKey:@"latitud"];
coord = [data objectForKey:@"longitud"];
NSLog(@"Dictionary: %@", [coord description])!
但只填一个键。有什么想法吗?坦克!
答案 0 :(得分:1)
您的代码:
你将不得不更清楚地描述你想要做的事情。
您可能会这样做:
NSString *key;
id anObject;
key = @"latitud";
anObject = [data objectForKey: key];
[coord setObject: anObject forKey: key];
key = @"longitud";
anObject = [data objectForKey: key];
[coord setObject: anObject forKey: key];