我想知道是否可以将值设置为字典中的字典。字典作为值 - 用当前值覆盖NSMutableDictionary的所有其他值
我想将值设置为字典,但是当我为当前键设置值时,所有以前的键也会使用此值设置。
[self.mainDict setValue:self.buttonDict forKey:[NSString stringWithFormat:@"%d",device.deviceID]];
这里是我得到两次迭代:
main Dict {
2 = {
1 = (
"object1",
"object2"
);
};
}
第二
main Dict {
2 = {
1 = (
"object3",
"object4"
);
};
3 = {
1 = (
"object3",
"object4"
);
};
}
词典应该能够接受任何形式的价值正确?我怀疑问题是其他问题
不,“NSDictionary”不接受任何值。 _Keys_必须符合'NSCopying'协议([documentation](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/index.html#//apple_ref/occ/) instm/NSMutableDictionary/setObject:forKey :)) – Arc676
你可以与字典值分享你的代码吗? – Vijay
@vijay:输出中的值? – Masood