Initializer

init(object:forKey:)

Creates a dictionary containing a given key and value.

Declaration

convenience init(object: Any, forKey key: NSCopying)

Parameters

anObject

The value corresponding to aKey.

If this value is nil, an invalidArgumentException is raised.

aKey

The key for anObject.

If this value is nil, an invalidArgumentException 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

init(objects: [Any], forKeys: [NSCopying])

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

init(objects: UnsafePointer<AnyObject>?, forKeys: UnsafePointer<NSCopying>?, count: Int)

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