[Array objectAtIndex: row]
Modify the above in the key of "aa" value
NSMutableDictionary * item = [[NSMutableDictionary alloc] init];
item = [array objectAtIndex: row];
[Item setObject: @ "222" forKey: @ "aa"];
Error: [__NSCFDictionary setObject: forKey:]: mutating method sent to immutable object '
Thank you seniors doubts under the ball. .
Reply:
Because the array in the dictionary are immutable, with a variable dictionary to write back
Reply:
NSMutableDictionary * item = [[NSMutableDictionary alloc] init];
item = [array objectAtIndex: row];
[Item setObject: @ "222" forKey: @ "aa"];
This. . . You wording problems. . .
First, the first one, to generate a variable dictionary (assuming address is 0x000001)
Second sentence, an address to you vice item, then you have just generated 000001 will be found. . .
NSObject * obj = [array objectAtIndex: row] (assuming address 000002)
item address is 000002.000001 not visit your old address, and became a physical presence but not get access address (memory leaks, there arc exceptions)
You should: item addEntributeFrom: (NSDictionary *) dic
000002 000001 Address was added inside the dictionary dictionaries have attributes. . . .
As variable as an array. . .
Reply:
NSDictionary * item = [array objectAtIndex: row];
NSMutableDictionary * mutableItem = [NSMutableDictionary dictionaryWithDictionary: item];
[MutableItem setObject: @ "222" forKey: @ "aa"];
[Array setObject: mutableItem atIndexedSubscript: row]
No comments:
Post a Comment