Reputation: 5435
I have an NSMutableDictionary.
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
I have to update an element in that dictionary. How i can do that?
Upvotes: 9
Views: 26697
Reputation: 6373
NSMutableDictionary's method addEntriesFromDictionary.
If both dictionaries contain the same key, the receiving dictionary’s previous value object for that key is sent a release message, and the new value object takes its place.
Upvotes: 2
Reputation: 1232
dictionary only allows you to have one objects for each key so if you use "set object for key" it will update the current one
Upvotes: 2
Reputation: 6539
Please refer to the API here
First retrieve the objects using
[dict objectForKey:@"key"];
Later, you can set them back using:
- (void)setObject:(id)anObject forKey:(id)aKey
- (void)setValue:(id)value forKey:(NSString *)key
Upvotes: 12