I have an NSMutableDictionary.
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
I have to update an element in that diction开发者_运维技巧ary. How i can do that?
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
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
NSMutableDictionary's method addEntriesFromDictionary.
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/Reference/Reference.html
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.
精彩评论