---
title: "indexPath(for:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscollectionview/indexpath(for:)"
---

# indexPath(for:)

Returns the index path of the specified item.

## Declaration

```swift
func indexPath(for item: NSCollectionViewItem) -> IndexPath?
```

## Parameters

- `item`: The item whose index path you want to know.

## Return Value

Return Value The item’s index path or nil if the item is not in the collection view.

## See Also

### Locating Items and Views

- [visibleItems()](appkit/nscollectionview/visibleitems().md)
- [indexPathsForVisibleItems()](appkit/nscollectionview/indexpathsforvisibleitems().md)
- [visibleSupplementaryViews(ofKind:)](appkit/nscollectionview/visiblesupplementaryviews(ofkind:).md)
- [indexPathsForVisibleSupplementaryElements(ofKind:)](appkit/nscollectionview/indexpathsforvisiblesupplementaryelements(ofkind:).md)
- [indexPathForItem(at:)](appkit/nscollectionview/indexpathforitem(at:).md)
- [item(at:)](appkit/nscollectionview/item(at:)-2vx2h.md)
- [supplementaryView(forElementKind:at:)](appkit/nscollectionview/supplementaryview(forelementkind:at:).md)
- [scrollToItems(at:scrollPosition:)](appkit/nscollectionview/scrolltoitems(at:scrollposition:).md)
