Class

NSIndexPath

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

Declaration

@interface NSIndexPath : NSObject

Overview

Each index in an index path represents the index into an array of children from one node in the tree to another, deeper, node. For example, the index path 1.4.3.2 specifies the path shown in Figure 1.

Figure 1

Index path 1.4.3.2

Index path “1.4.3.2”

Topics

Creating and Initializing Index Paths

+ indexPathWithIndex:

Creates a one-node index path.

+ indexPathWithIndexes:length:

Creates an index path with one or more nodes.

- initWithIndex:

Initializes an index path with a single node.

- initWithIndexes:length:

Initializes an index path with the given nodes and length.

Using Special Node Names

UIKit and AppKit supply specialized names for the first two index path nodes for use when working with table views and collection views.

+ indexPathForRow:inSection:

Initializes an index path with the indexes of a specific row and section in a table view.

+ indexPathForItem:inSection:

Initializes an index path with the indexes of a specific item and section in a collection view.

section

An index number identifying a section in a table view or collection view.

row

An index number identifying a row in a section of a table view.

item

An index number identifying an item in a section of a collection view.

Counting Nodes

length

The number of nodes in the index path.

Adding and Removing Nodes

- indexPathByAddingIndex:

Returns an index path containing the nodes in the receiving index path plus another given index.

- indexPathByRemovingLastIndex

Returns an index path with the nodes in the receiving index path, excluding the last one.

Comparing Index Paths

- compare:

Indicates the depth-first traversal order of the receiving index path and another index path.

Working with Indexes

- indexAtPosition:

Provides the value at a particular node in the index path.

- getIndexes:range:

Copies the indexes stored in the index path from the positions specified by the position range into the specified indexes.

- getIndexes:

Copies the objects contained in the index path into indexes.

Deprecated

Relationships

Inherits From

See Also

Indexes

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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software