NSMutableDictionary *mutableDict = [[NSMutableDictionary alloc] initWithDictionary:self.mappingDict];
creates a new dictionary containing the keys and values of self.mappingDict
, but it
does not copy the values, which means that
mutableDict[@"displayValues"]
still refers to the the value in self.mappingDict
and you are modifying the same
dictionary in each step of the loop. Try
NSMutableDictionary *mutableDict = [[NSMutableDictionary alloc] initWithDictionary:self.mappingDict
copyItems:YES];
instead.
Update: This does also not work because copyItems:YES
causes the subdirectories to be
copied, which makes them immutable. What you need is a "deep mutable copy" where
all subdirectories are also mutable.
But there is an easier solution. Instead of copying self.mappingDict
, just re-read it
from the plist as a mutable dictionary:
NSMutableDictionary *mutableDict = [NSMutableDictionary dictionaryWithContentsOfFile:mappingPlistPath];
This gives you independent mutable dictionaries for each enumeration step in the loop.