ios 往可变字典添加object会覆盖到上一个key的值啊!!怎么解决!有代码~~

self.arr=[NSMutableArray new];
self.dic=[NSMutableDictionary new];
[self.arr addObjectsFromArray:@[@"1",@"2",@"3"]];
[self.dic setObject:self.arr forKey:@"key1"];

[self.arr removeAllObjects];
[self.arr addObjectsFromArray:@[@"3",@"4",@"5"]];
[self.dic setObject:self.arr forKey:@"key2"];

NSLog(@"%@",self.dic);



    输出结果:
    {
key1 =     (
    3,
    4,
    5
);
key2 =     (
    3,
    4,
    5
);

}

查看全部
qq_29574501
Xing_1102
2016/02/28 05:22
  • 对象
  • nsmutablearray
  • ios
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

5个回复