Search code examples
iphoneobjective-cnsdictionarynsmutabledictionary

How to update NSMutableDictionary?


I have an NSMutableDictionary.

NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];

I have to update an element in that dictionary. How i can do that?


Solution

  • 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