Create empty dictionary

NSDictionary *dict = [NSDictionary dictionary];

Create a dictionary with one key/value pair

NSDictionary *dict = [NSDictionary dictionaryWithObject:@"value" forKey:@"key"];

Create a dictionary with arrays of keys and values

NSArray *keys = [NSArray arrayWithObjects:@"One", @"Two", @"Three", nil];
NSArray *values = [NSArray arrayWithObjects:@"Uno", @"Duo", @"Tre", nil];
NSDictionary *dict = [NSDictionary dictionaryWithObjects:values forKeys:keys];

Create a dictionary with list of values and keys

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil];

Create a dictionary with content of another dictionary

NSDictionary *dict = [NSDictionary dictionaryWithDictionary:anotherDict];

Read a dictionary from file

NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:@"/path/to/file"];

Read a dictionary from URL

NSDictionary *dict = [NSDictionary dictionaryWithContentsOfURL:url];

Get number of elements in the dictionary

NSUInteger count = [dict count];

Compare two dictionaries

BOOL equal = [dict isEqualToDictionary:anotherDict];

Get all keys in the dictionary

NSArray *keys = [dict allKeys];

Get all keys corresponding to all occurrences of object in the dictionary

NSArray *keys = [dict allKeysForObject:obj];

Get all values in the dictionary

NSArray *values = [dict allValues];

Get value for the key in the dictionary

id obj = [dict objectForKey:@"key"];

Get values for multiple keys in the dictionary

NSArray *keys = [NSArray arrayWithObjects:@"one", @"two", nil];
NSArray *values = [dict objectsForKeys:keys notFoundMarker:defaultObj];

Enumerate keys and objects in the dictionary using block

[dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop){
    // Do something useful

Get dictionary's keys for values in order sorted using given selector

// values of dict are NSString
NSArray *sortedKeys = [dict keysSortedByValueUsingSelector:@selector(caseInsensitiveCompare:)];

Get dictionary's keys for values in order sorted using given comparator

// values of dict are NSString
NSArray *sortedKeys = [dict keysSortedByValueUsingComparator:^(id obj1, id obj2) {
    if ([obj1 relevance] > [obj2 relevance]) {
        return (NSComparisonResult)NSOrderedDescending;

    if ([obj1 relevance] < [obj2 relevance]) {
        return (NSComparisonResult)NSOrderedAscending;

    return (NSComparisonResult)NSOrderedSame;

Get keys for dictionary's values that pass given test

// Result is set of keys for object with length more than one character 
NSSet* keys = [dict keysOfEntriesPassingTest:^(id key, id obj, BOOL *stop) {
    if ([obj length] > 1)
        return YES;
        return NO;

Write the dictionary to file

[dict writeToFile:@"/path/to/file" atomically:YES];

Write the dictionary to URL

[dict writeToURL:url atomically:YES];

Format the dictionary as a property list

NSString *plist = [dict description];

Format the dictionary as a .strings file

NSString *plist = [dict descriptionInStringsFileFormat];

Create mutable copy of the dicitonary

NSMutableDictionary *mutable = [dict mutableCopy];