Showing posts with label NSMutableDictionary setValue forKey example. Show all posts
Showing posts with label NSMutableDictionary setValue forKey example. Show all posts

Wednesday, June 19, 2013

NSMutableDictionary setValue forKey example in Objective C (iOS).


NSMutableDictionary setValue forKey

Adds a given key-value pair to the dictionary.

- (void)setValue:(id)value forKey:(NSString *)key

Parameters of [NSMutableDictionary setValue forKey]
value
The value for key.
key
The key for value. Note that when using key-value coding, the key must be a string (see “Key-Value Coding Fundamentals”).

Discussion of [NSMutableDictionary setValue forKey]
This method adds value and key to the dictionary using setObject:forKey:, unless value is nil in which case the method instead attempts to remove key using removeObjectForKey:.

NSMutableDictionary setValue forKey example.
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setValue:[NSNumber numberWithBool:news] forKey:@"news"];
[parameters setValue:[NSNumber numberWithBool:mails] forKey:@"mails"];

End of NSMutableDictionary setValue forKey example article.