[array objectAtIndex:row]
修改上面中key为“aa”的值
NSMutableDictionary *item = [[NSMutableDictionary alloc]init];
item=[array objectAtIndex:row];
[item setObject:@“222” forKey:@"aa"];
报错:[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'球各位前辈解惑下 谢谢。。
修改上面中key为“aa”的值
NSMutableDictionary *item = [[NSMutableDictionary alloc]init];
item=[array objectAtIndex:row];
[item setObject:@“222” forKey:@"aa"];
报错:[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'球各位前辈解惑下 谢谢。。
item=[array objectAtIndex:row];
[item setObject:@“222” forKey:@"aa"];这个你写法有问题首先第一句,生成一个 可变 字典(假设地址为 0x000001)
第二句,你副了一个 地址 给 item,那么 你刚生成得000001会找不到
NSObject *obj = [array objectAtIndex: row] (假设地址 000002)
item 地址 为 000002. 000001地址你旧访问不到了,变成了一个 实际存在而又访问不到得地址(内存泄漏,有arc 例外)你应当: item addEntributeFrom :(NSDictionary *)dic
000001地址得字典 添加 000002字典里面得属性。就像可变数组那样
NSMutableDictionary *mutableItem = [NSMutableDictionary dictionaryWithDictionary:item];
[mutableItem setObject:@“222” forKey:@"aa"];
[array setObject: mutableItem atIndexedSubscript:row]