NSMutableDictionary *mutDic;
其加载与其他NSMutableDictionary
从提示的一些值我试图更新它的值
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
[self.mutDic setValue:[[alertView textFieldAtIndex:0] text] forKey:@"lname"];
}
,但我得到这个例外
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'
我们如何更新字典?
崩溃日志说你的字典是不是可变初始化它。你能告诉我们你如何分配/初始化字典吗? – 2012-02-06 08:18:44
如果您在@property中有'copy',则用'retain'或'strong'替换它。复制总是创建不可变的对象。 – 2012-02-06 08:26:22