0

我有一个NSDictionary和一个NSMutableArray我想从一个键存储许多对象,NSDictionaryNSMutableArray我不知道。

这是我的代码:

//NSArray * a = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"7",@"9", nil];
//NSArray *b = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"0", nil];
NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys:a,@"number1",b,@"number2", nil];

NSMutableArray *array = [NSMutableArray alloc].... ?

我想将对象存储在来自 in 的 number1 键NSDictionaryNSMutableArray

4

2 回答 2

1

由于您似乎将数组存储为NSDictionary元素,因此您可以这样做:

NSMutableArray *array = [[NSMutableArray alloc] initiWithArray:dic[@"number1"]];

或者

NSMutableArray *array = [NSMutableArray arrayWithArray:dic[@"number1"]];
于 2013-06-03T09:59:59.230 回答
0

要将对象添加到NsDictionary数组中,请执行以下操作:

NSMutableDictionary * datos = [array objectAtIndex:i];
[datos setObject:@"hola" objectForKey@"newKey"];
于 2015-08-14T20:58:40.150 回答