<!--
{
  "availability" : [
    "macOS: 10.15.1 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCollectionViewDiffableDataSource-axww/indexPath(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "s:6AppKit34NSCollectionViewDiffableDataSourceC9indexPath3for10Foundation05IndexI0VSgq__tF"
  },
  "title" : "indexPath(for:)"
}
-->

# indexPath(for:)

Returns an index path for the item with the specified identifier in the collection view.

```
func indexPath(for itemIdentifier: ItemIdentifierType) -> IndexPath?
```

## Parameters

`itemIdentifier`

The identifier of the item in the collection view.

## Return Value

The item’s index path, or `nil` if no item is found with the provided item identifier.

## Discussion

This method is a constant time operation, O(1), which means you can look up an index path from its corresponding item identifier with no significant overhead.

---

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)