コードに問題はありません[[anArray objectAtIndex:index] setValue:newValue forKey:someKey];
NSMutableDictionary
このように追加する必要があります
NSMutableArray *myArray = [[NSMutableArray alloc] init];
NSMutableDictionary *dict1 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"dict1value1", @"key1", @"dict1value2", @"key2", nil];
[myArray addObject:[dict1 copy]];
[myArray addObject:dict1];
[[myArray objectAtIndex:1] setValue:@"NEW VALUE" forKey:@"key2"];
NSLog(@"%@",[myArray objectAtIndex:0]);
NSLog(@"%@",[myArray objectAtIndex:1]);
また
NSMutableArray *myArray = [[NSMutableArray alloc] init];
NSMutableDictionary *dict1 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"dict1value1", @"key1", @"dict1value2", @"key2", nil];
NSMutableDictionary *dict2 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"dict2value1", @"key1", @"dict2value2", @"key2", nil];
[myArray addObject:dict1];
[myArray addObject:dict2];
[[myArray objectAtIndex:1] setValue:@"NEW VALUE" forKey:@"key2"];
NSLog(@"%@",[myArray objectAtIndex:0]);
NSLog(@"%@",[myArray objectAtIndex:1]);
出力
{
key1 = dict1value1;
key2 = dict1value2;
}
{
key1 = dict1value1;
key2 = "NEW VALUE";
}