Reputation: 12184
When I read a plist for a dictionary which is not empty and has at-least one key value pair into an NSMutableDictionary property of my model class, Everything works fine. I can add,delete modify the mutable dictionary.
But when the dictionary is empty
and you can see the plist with a tag like this :
<dict/>
Then, even though my property has an NSMutableDictionary pointer, Object which is created becomes immutable.
and when I try to set an object in it for a particular property, It gives me this error saying:
'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'
Upvotes: 1
Views: 228
Reputation: 16022
Pretty sure all objects retrieved from a plist are the immutable variants. I do think I saw an option to deserialize them as mutable however.
Edit:
this article explains how to unarchive a plist as mutable:
http://cocoadev.com/wiki/PropertyList
Upvotes: 1
Reputation: 29498
NSMutableDictionary *mutable = [yourApparentlyMutableDictionary mutableCopy];
Upvotes: 2