Class

NSIndexPath

An object containing a list of indexes that bridges to IndexPath; use NSIndexPath when you need reference semantics or other Foundation-specific behavior.

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

init(index: Int)

Initializes an index path with a single node.

init(indexes: UnsafePointer<Int>?, length: Int)

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.

init(row: Int, section: Int)

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

init(item: Int, section: Int)

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

var section: Int

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

var row: Int

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

var item: Int

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

Counting Nodes

var length: Int

The number of nodes in the index path.

Adding and Removing Nodes

func adding(Int)

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

func removingLastIndex()

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

Comparing Index Paths

func compare(IndexPath)

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

Working with Indexes

func index(atPosition: Int)

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

func getIndexes(UnsafeMutablePointer<Int>, range: NSRange)

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

func getIndexes(UnsafeMutablePointer<Int>)

Copies the objects contained in the index path into indexes.

Deprecated

Relationships

Inherits From

See Also

Using Reference Types

typealias IndexPath.ReferenceType

An alias for this value type's equivalent reference type.