<!--
{
  "documentType" : "article",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/collections",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Collections"
}
-->

# Collections

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

## Topics

### Basic Collections

  <doc://com.apple.documentation/documentation/Swift/Array>

  <doc://com.apple.documentation/documentation/Swift/Dictionary>

  <doc://com.apple.documentation/documentation/Swift/Set>

### Basic Collections

[`NSArray`](/documentation/Foundation/NSArray)

A static ordered collection of objects.

[`NSMutableArray`](/documentation/Foundation/NSMutableArray)

A dynamic ordered collection of objects.

[`NSDictionary`](/documentation/Foundation/NSDictionary)

A static collection of objects associated with unique keys.

[`NSMutableDictionary`](/documentation/Foundation/NSMutableDictionary)

A dynamic collection of objects associated with unique keys.

[`NSSet`](/documentation/Foundation/NSSet)

A static, unordered collection of unique objects.

[`NSMutableSet`](/documentation/Foundation/NSMutableSet)

A dynamic unordered collection of unique objects.

### Indexes

[`IndexPath`](/documentation/Foundation/IndexPath)

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

[`IndexSet`](/documentation/Foundation/IndexSet)

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

### Indexes

[`NSIndexPath`](/documentation/Foundation/NSIndexPath)

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

[`NSIndexSet`](/documentation/Foundation/NSIndexSet)

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

[`NSMutableIndexSet`](/documentation/Foundation/NSMutableIndexSet)

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

### Specialized Sets

[`NSCountedSet`](/documentation/Foundation/NSCountedSet)

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

[`NSOrderedSet`](/documentation/Foundation/NSOrderedSet)

A static, ordered collection of unique objects.

[`NSMutableOrderedSet`](/documentation/Foundation/NSMutableOrderedSet)

A dynamic, ordered collection of unique objects.

### Purgeable Collections

[`NSCache`](/documentation/Foundation/NSCache)

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

[`NSPurgeableData`](/documentation/Foundation/NSPurgeableData)

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

### Pointer Collections

[`NSPointerArray`](/documentation/Foundation/NSPointerArray)

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

[`NSMapTable`](/documentation/Foundation/NSMapTable)

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

[`NSHashTable`](/documentation/Foundation/NSHashTable)

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

### Iteration

[`NSEnumerator`](/documentation/Foundation/NSEnumerator)

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

[`NSFastEnumeration`](/documentation/Foundation/NSFastEnumeration)

A protocol that objects adopt to support fast enumeration.

[`NSFastEnumerationIterator`](/documentation/Foundation/NSFastEnumerationIterator)

[`NSIndexSetIterator`](/documentation/Foundation/NSIndexSetIterator)

An iterator suitable for enumerating the elements of an index set.

[`NSEnumerationOptions`](/documentation/Foundation/NSEnumerationOptions)

Options for block enumeration operations.

[`NSSortOptions`](/documentation/Foundation/NSSortOptions)

Options for block sorting operations.

### Special Semantic Values

[`NSNull`](/documentation/Foundation/NSNull)

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

[`NSNotFound`](/documentation/Foundation/NSNotFound-9t5v2)

[`NSNotFound`](/documentation/Foundation/NSNotFound-4qp9h)

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



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)