给不可变数组设置新的key
NSDictionary *dict=@{@"key1":@0};
[dict setValue:@5 forKey:@"key1"];
NSLog(@"dict1 ==%@",dict);
[dict setValue:@5 forKey:@"key2"];
NSLog(@"dict2 ==%@",dict);
打印内容
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<__NSDictionaryI 0x7b6c71c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key key1.'
解决方案
使用可变字典就可以