Type Method

dictionaryWithObject:forKey:

Creates a dictionary containing a given key and value.

Declaration

+ (instancetype)dictionaryWithObject:(ObjectType)object forKey:(id<NSCopying>)key;

Parameters

anObject

The value corresponding to aKey.

If this value is nil, an NSInvalidArgumentException is raised.

aKey

The key for anObject.

If this value is nil, an NSInvalidArgumentException is raised.

Return Value

A new dictionary containing a single object, anObject, for a single key, aKey.

See Also

Creating a Dictionary from Objects and Keys

+ dictionaryWithObjects:forKeys:

Creates a dictionary containing entries constructed from the contents of an array of keys and an array of values.

+ dictionaryWithObjects:forKeys:count:

Creates a dictionary containing a specified number of objects from a C array.

- initWithObjects:forKeys:

Initializes a newly allocated dictionary with key-value pairs constructed from the provided arrays of keys and objects.

- initWithObjects:forKeys:count:

Initializes a newly allocated dictionary with the specified number of key-value pairs constructed from the provided C arrays of keys and objects.

+ dictionaryWithObjectsAndKeys:

Creates a dictionary containing entries constructed from the specified set of values and keys.

- initWithObjectsAndKeys:

Initializes a newly allocated dictionary with entries constructed from the specified set of values and keys.