我需要以下的结果:的NSDictionary内的NSMutableArray(IOS)
(
"some_key" = {
"another_key" = "another_value";
};
);
为了做到这一点,我有这样的代码,但它不工作:
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"another_value", @"another_key", nil];
NSMutableArray *array = [[NSMutableArray alloc] init];
[array setValue:dictionary forKey:@"some_key"];
任何理念?谢谢!
的当我' NSLog'数组,它返回'()'。 – 2013-03-22 16:06:51
您提供了混合数组和字典语法的示例。目前还不清楚结果应该是字典还是数组。 – 2013-03-22 16:13:28
@NikolaiRuhe实际上,'setValue:forKey:'作为NSArray的KVC访问器是完全有效的。由于该数组是空的,它什么都不做。 – Monolo 2013-03-22 16:15:05