I have an iPhone application that makes use of an API. Among the API calls, there’s one that returns a JSON Dictionary with 3 arrays, each of them containing a set of dictionaries.
Here’s how i’m using it:
NSMutableDictionary * allthethings [self FetchAllTheThings]; // Returns the big dictionary
NSMutableArray * oneofthethings = [NSMutableArray arrayWithArray: [allthethings valueForKey:@"First"]];
etc etc.
Then when I’m looping through the “oneofthethings” array and setting a new value on one of the dicts i get a SIGABRT, presumably because the dictionaries contained within are not mutable.
So my question is this: Is there any way to sort of tell the array to store them as mutables? Or will i have to loop through it and copy each of the dictionaries to a mutable analog?
I think you are going to have to create a mutable copy. Nsdictionary has a mutableCopy method to make it easy, but you can imagine this would be inefficient if called a lot