<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/IndexPath",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation9IndexPathV"
  },
  "title" : "IndexPath"
}
-->

# IndexPath

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

```
struct IndexPath
```

## 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.

## Topics

### Creating Index Paths

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

Creates an empty index path.

[`init(index:)`](/documentation/Foundation/IndexPath/init(index:))

Creates an index path with a single element.

[`init(arrayLiteral:)`](/documentation/Foundation/IndexPath/init(arrayLiteral:))

Creates an index path from an array literal.

[`init(indexes:)`](/documentation/Foundation/IndexPath/init(indexes:)-7auqk)

Creates an index path from an array of elements.

[`init(indexes:)`](/documentation/Foundation/IndexPath/init(indexes:)-55we8)

Creates an index path from a sequence of integers.

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

A type that represents one node of an index path.

### Working with Special Node Names

<doc://com.apple.documentation/documentation/UIKit> and <doc://com.apple.documentation/documentation/AppKit> supply specialized names for the first two index path nodes for use when working with table views and collection views.

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

One past the index of the last node in the index path.

[`item`](/documentation/Foundation/IndexPath/item-8cp0y)

The value of the item element of the index path.

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

The value of the row element of the index path.

[`section`](/documentation/Foundation/IndexPath/section-8h7wo)

The value of the section element of the index path.

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

The index of the first node in the index path.

### Counting Nodes

### Accessing Nodes

[`subscript(_:)`](/documentation/Foundation/IndexPath/subscript(_:)-6p6ul)

Accesses one of the index path’s nodes.

[`subscript(_:)`](/documentation/Foundation/IndexPath/subscript(_:)-4pgu1)

Accesses a contiguous subrange of the index path’s nodes.

### Adding Nodes

[`+(_:_:)`](/documentation/Foundation/IndexPath/+(_:_:))

Combines the elements of two index paths into a single index path.

[`+=(_:_:)`](/documentation/Foundation/IndexPath/+=(_:_:))

Appends the elements of another index path to this index path.

### Removing Nodes

### Finding Nodes

### Selecting Nodes

[`append(_:)`](/documentation/Foundation/IndexPath/append(_:)-6dxrh)

Appends the nodes of another index path to this one.

[`append(_:)`](/documentation/Foundation/IndexPath/append(_:)-6vsd5)

Appends an array of elements to this index path as additional nodes.

[`append(_:)`](/documentation/Foundation/IndexPath/append(_:)-7qv6f)

Appends a single element to this index path as a new node.

[`appending(_:)`](/documentation/Foundation/IndexPath/appending(_:)-93eco)

Returns a new index path containing the elements of this one plus the given element.

[`appending(_:)`](/documentation/Foundation/IndexPath/appending(_:)-53tcl)

Returns a new index path containing the elements of this one plus those of another index path.

[`appending(_:)`](/documentation/Foundation/IndexPath/appending(_:)-174v0)

Returns a new index path containing the elements of this one plus an array of additional elements.

[`compare(_:)`](/documentation/Foundation/IndexPath/compare(_:))

Compares this index path to another in depth-first traversal order.

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

Return a new index path containing all but the last element.

[`index(after:)`](/documentation/Foundation/IndexPath/index(after:))

Returns the index that follows the given index.

[`index(before:)`](/documentation/Foundation/IndexPath/index(before:))

Returns the index that precedes the given index.

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

Returns an iterator over the nodes of the index path.

### Excluding Nodes

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

Return a new index path containing all but the last element.

### Transforming Index Paths

### Iterating over Nodes

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

Returns an iterator over the nodes of the index path.

### Sorting Nodes

### Comparing Index Paths

[`compare(_:)`](/documentation/Foundation/IndexPath/compare(_:))

Compares this index path to another in depth-first traversal order.

### Manipulating Indexes

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

A type that points to a particular node in an index path, similar to an array index.

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

The index of the first node in the index path.

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

One past the index of the last node in the index path.

[`index(after:)`](/documentation/Foundation/IndexPath/index(after:))

Returns the index that follows the given index.

[`index(before:)`](/documentation/Foundation/IndexPath/index(before:))

Returns the index that precedes the given index.

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

A type that represents a group of nodes in an index path.

### Using Reference Types

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

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

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Copyable`](/documentation/Swift/Copyable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Encodable`](/documentation/Swift/Encodable)

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

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`Collection`](/documentation/Swift/Collection)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Decodable`](/documentation/Swift/Decodable)

[`Hashable`](/documentation/Swift/Hashable)

[`BidirectionalCollection`](/documentation/Swift/BidirectionalCollection)

[`Sequence`](/documentation/Swift/Sequence)

[`MutableCollection`](/documentation/Swift/MutableCollection)

[`RandomAccessCollection`](/documentation/Swift/RandomAccessCollection)

[`Escapable`](/documentation/Swift/Escapable)

[`CustomReflectable`](/documentation/Swift/CustomReflectable)

[`Comparable`](/documentation/Swift/Comparable)

[`ExpressibleByArrayLiteral`](/documentation/Swift/ExpressibleByArrayLiteral)

---

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)