Collections

Use arrays, dictionaries, sets, and specialized collections to store and iterate groups of objects or values.

Topics

Basic Collections

NSArray

A static ordered collection of objects.

NSMutableArray

A dynamic ordered collection of objects.

NSDictionary

A static collection of objects associated with unique keys.

NSMutableDictionary

A dynamic collection of objects associated with unique keys.

NSSet

A static unordered collection of unique objects.

NSMutableSet

A dynamic unordered collection of unique objects.

Indexes

NSIndexPath

A list of indexes that together represent the path to a specific location in a tree of nested arrays.

NSIndexSet

An immutable collection of unique integer values that represent indexes in another collection.

NSMutableIndexSet

A mutable collection of unique integer values that represent indexes in another collection.

Specialized Sets

NSCountedSet

A mutable, unordered collection of distinct objects that may appear more than once in the collection.

NSOrderedSet

A static, ordered collection of unique objects.

NSMutableOrderedSet

A dynamic, ordered collection of unique objects.

Purgeable Collections

NSCache

A mutable collection you use to temporarily store transient key-value pairs that are subject to eviction when resources are low.

NSPurgeableData

A mutable data object containing bytes that can be discarded when they're no longer needed.

Pointer Collections

NSPointerArray

A collection similar to an array, but with a broader range of available memory semantics.

NSMapTable

A collection similar to a dictionary, but with a broader range of available memory semantics.

NSHashTable

A collection similar to a set, but with broader range of available memory semantics.

Iteration

NSEnumerator

An abstract class whose subclasses enumerate collections of objects, such as arrays and dictionaries.

NSFastEnumeration

A protocol that objects adopt to support fast enumeration.

NSEnumerationOptions

Options for block enumeration operations.

NSSortOptions

Options for block sorting operations.

Special Semantic Values

NSNull

A singleton object used to represent null values in collection objects that don’t allow nil values.

NSNotFound

A value indicating that a requested item couldn’t be found or doesn’t exist.

See Also

Fundamentals

Numbers, Data, and Basic Values

Work with primitive values and other fundamental types used throughout Cocoa.

Strings and Text

Create and process strings of Unicode characters, use regular expressions to find patterns, and perform natural language analysis of text.

Dates and Times

Compare dates and times, and perform calendar and time zone calculations.

Units and Measurement

Label numeric quantities with physical dimensions to allow locale-aware formatting and conversion between related units.

Data Formatting

Convert numbers, dates, measurements, and other values to and from locale-aware string representations.

Filters and Sorting

Use predicates, expressions, and sort descriptors to examine elements in collections and other services.