Contents

NSIndexSet

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

Declaration

class NSIndexSet

Overview

In Swift, this type bridges to IndexSet; use NSIndexSet when you need reference semantics or other Foundation-specific behavior.

The NSIndexSet class represents an immutable collection of unique unsigned integers, known as indexes because of the way they are used. This collection is referred to as an index set. Indexes must be in the range 0 .. NSNotFound - 1.

You use index sets in your code to store indexes into some other data structure. For example, given an NSArray object, you could use an index set to identify a subset of objects in that array.

You should not use index sets to store an arbitrary collection of integer values because index sets store indexes as sorted ranges. This makes them more efficient than storing a collection of individual integers. It also means that each index value can only appear once in the index set.

The designated initializers of the NSIndexSet class are: init(index:), init(indexesIn:), and init(indexSet:).

You must not subclass the NSIndexSet class.

The mutable subclass of NSIndexSet is NSMutableIndexSet.

Topics

Creating Index Sets

Querying Index Sets

Enumerating Index Set Content

Comparing Index Sets

Getting Indexes

Enumerating Indexes

Initializers

Default Implementations