小编alr*_*rea的帖子

如何更新NSMutableDictionary

我有

NSMutableDictionary *mutDic;
Run Code Online (Sandbox Code Playgroud)

NSMutableDictionary 从一个警报中加载了一些来自我试图更新其值的警报值

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    [self.mutDic setValue:[[alertView textFieldAtIndex:0] text] forKey:@"lname"];
}
Run Code Online (Sandbox Code Playgroud)

但我得到了这个例外

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'
Run Code Online (Sandbox Code Playgroud)

我们如何更新字典?

iphone nsmutabledictionary xcode4

2
推荐指数
1
解决办法
2757
查看次数

标签 统计

iphone ×1

nsmutabledictionary ×1

xcode4 ×1