I have this value inside my NSMutableArray called myMutableArray
:
(
{
"name_user" = xxxxxx;
"user_key" = "xxxxxxx";
}
Believing that within this array there is a dictionary (as seen above), let's assume I wanted to add another dictionary in this array to stay with a similar result like this:
(
{
"name_user" = xxxxxx;
"user_key" = "xxxxxxx";
},
{
"name_user" = aaaaaa;
"user_key" = "stack overflow";
}
For that I'm testing the following code:
[myMutableArray addObject:@[@{@"name_user":"stack overflow",@"user_key":@"aaaaaa"}]];
The problem with this code is that I'm getting the following error message:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
How can I solve this problem?
myMutableArray
is actually referencing an NSArray, not an NSMutableArray. Where do you create this array? – Paulw11NSJSONReadingMutableContainers
– Steven Fisher