How to insert a new key with value in dictionary
I want to insert a key with a corresponding value in an existing dictionary... I am able to set values for existing keys in the dictionary, but I am not able to add a new key value... Any help would be appreciated. Use NSMutableDictionary NSMutableDictionary *yourMutableDictionary = [NSMutableDictionary alloc] init]; [yourMutableDictionary setObject:@"Value" forKey:@"your key"]; Update for Swift: The following is the exact swift replica for the code mentioned above var yourMutableDictionary = NSMutableDictionary() yourMutableDictionary.setObject("Value", forKey: "Key") But i would suggest you