Reputation: 27608
I have a NSMutableDictionary with one key and it has the following values.
How can I change the value in item2 from 1 to 0? That's the only change I need.
The only way I have found is to recreate this whole key from scratch, change that one value and then delete that key and replace it with a new one. Is there any easier solution than that?
Upvotes: 1
Views: 508
Reputation: 2568
I will assume you get dict
as an instance of NSMutableDictionary
somehow:
NSMutableArray *tmp = [dict[@"07:00 AM.infoKey"] mutableCopy];
tmp[2] = @"0";
dict[@"07:00 AM.infoKey"] = tmp;
Unfortunately with nested arrays in dictionaries, the arrays aren't automatically mutable so there isn't any better method to doing so, like you observed.
Upvotes: 4