I'm reading into my application a plist which at the top level is an array. It's simple enough to make sure the array starts as mutable
self.plistData = [[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"myDataSource" ofType:@"plist"]] mutableCopy];
Within each element of the array is another array, each of those contains a dictionary.
Based on a tablecell selection I'm changing attributes for the dictionary at the selected index:
[self.cellDescriptors[indexPath.section][indexOfTappedRow] setValue:@"YES" forKey: @"isSelected"];
I'm getting the error '-[__NSCFDictionary removeObjectForKey:]: mutating method sent to immutable object'
when I attempt to change a dictionary value. The error makes sense if the NSDictionary read in by the plist is immutable.
Is there any way to read in content from a plist and make sure any arrays or dictionaries are read in as mutable versions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…