Creates a dictionary containing a specified number of objects from a C array.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
A C array of values for the new dictionary.
A C array of keys for the new dictionary. Each key is copied (using
copyWithZone:; keys must conform to the
NSCopying protocol), and the copy is added to the new dictionary.
The number of elements to use from the
count must not exceed the number of elements in
This method steps through the
keys arrays, creating entries in the new dictionary as it goes. An
NSInvalidArgumentException is raised if a key or value object is
The following code fragment illustrates how to create a dictionary that associates the alphabetic characters with their ASCII values:
Creating a Dictionary from Objects and Keys
Initializes a newly allocated dictionary with key-value pairs constructed from the provided arrays of keys and objects.
Initializes a newly allocated dictionary with the specified number of key-value pairs constructed from the provided C arrays of keys and objects.
Initializes a newly allocated dictionary with entries constructed from the specified set of values and keys.