When you make this call
NSMutableDictionary* mainDictionary = [[NSMutableDictionary alloc] initWithDictionary:otherDictionary];
the only mutable dictionary that you are guaranteed to get is the outer one (i.e. the mainDictionary
). If objects inside otherDictionary
are mutable, they would remain mutable; if the objects inside otherDictionary
are immutable, they would remain immutable.
It appears that the otherDictionary
that you are passing to initWithDictionary:
has been constructed from a property list. If this is the case, you can force all its containers to be mutable by passing NSPropertyListMutableContainers
to the propertyListWithData:options:format:error:
method, like this:
NSMutableDictionary *otherDictionary = [NSPropertyListSerialization
propertyListWithData:myData
options:NSPropertyListMutableContainers
format:NULL
error:NULL
];