When I was working today, I was confronted with such a problem.
It was too careless. Mark,
2014-01-05 11:44:34.762 SOFTWAREAPP[1435:C07] * * * terminating app due to uncaught exception ' Nsinternalinconsistencyexception ', Reason: ' * * * *-[jkdictionary Setobject:forkey:]: Mutating method sent to immutable Object
First throw Call stack:
(0x285a012 0x1e48e7e 0x2859deb 0x36b96 0x18610ef 0x6c8df 0xabd61 0xac0f8 0x1e5c6b0 0x1bc3b 0x1e5c6b0 0x1888765 0x27ddf3f 0 x27dd96f 0x2800734 0x27fff44 0x27ffe1b 0x2a927e3 0x2a92668 0xd8cffc 0x2d5d 0x2551725 0x1)
Libc++abi.dylib:terminate called throwing an exception
Program ended with exit code:0
This is the code that reported the mistake.
[CPP]View Plaincopy
- nsdictionary *jsondata = [resultdic objectatindex:i];
- nsarray *eachlines = [[jsondata objectforkey:@" Newstime " ] componentsseparatedbystring:@ ". " ];  
- [jsondata setvalue:[eachlines objectatindex:0] forkey:@" Newstime " ];  
- [Testarr Addobject:jsondata];
... I think it's embarrassing to think about it now.
See reason: The following exception description: Meaning I have a variable corresponding to the method let an immutable call
Mutating method (variable counterpart): Methods that are owned by variables that can be changed after creation, such as Nsmutablearray,nsmutabledictionary
Immutable object (immutable variable): Variables that cannot be changed after they are created: such as Nsarray nsdictionary, etc.
After modification, it runs normally.
[CPP]View Plaincopy
- Nsmutabledictionary *jsondata = [Resultdic objectatindex:i];
- nsarray *eachlines = [[jsondata objectforkey:@" Newstime " ] componentsseparatedbystring:@ ". " ];  
- [jsondata setvalue:[eachlines objectatindex:0] forkey:@" Newstime " ];  
- [Testarr Addobject:jsondata];
iOS development-mutating method sent to immutable object error