Tutorial by Examples

NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil]; or NSArray *keys = [NSArray arrayWithObjects:@"key1", @"key2", nil]; NSArray *objects = [NSArray arrayWithObjects:@"va...
NSDictionary *myDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil]; NSArray *copiedArray = myDictionary.copy; Get keys: NSArray *keys = [myDictionary allKeys]; Get values: NSArray *values = [myDic...
NSDictionary *myDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil]; NSData *myData = [NSKeyedArchiver archivedDataWithRootObject:myDictionary]; Reserve path: NSDictionary *myDictionary = (NSDictionary*...
NSDictionary *myDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil]; NSMutableDictionary *mutableDictionary = [myDictionary mutableCopy]; NSData *data = [NSJSONSerialization dataWithJSONObject:myDiction...
Enumerating dictionaries allows you to run a block of code on each dictionary key-value pair using the method enumerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, BOOL *stop))block Example: NSDictionary stockSymbolsDictionary = @{ @"AAPL":...
NSDictionary can be enumerated using fast enumeration, just like other collection types: NSDictionary stockSymbolsDictionary = @{ @"AAPL": @"Apple", @"GOOGL": @"Alphabet", ...

Page 1 of 1