Instance Method

indexPath(for:)

Returns the index path of the specified item.

Declaration

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

Parameters

item

The item whose index path you want to know.

Return Value

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

See Also

Locating Items and Views

func visibleItems() -> [NSCollectionViewItem]

Returns an array of the actively managed items in the collection view.

func indexPathsForVisibleItems() -> Set<IndexPath>

Returns the index paths of the currently active items.

func visibleSupplementaryViews(ofKind: NSCollectionView.SupplementaryElementKind) -> [NSView & NSCollectionViewElement]

Returns an array of the actively managed supplementary views in the collection view.

func indexPathForItem(at: NSPoint) -> IndexPath?

Returns the index path of the item at the specified point.

func item(at: IndexPath) -> NSCollectionViewItem?

Returns the item associated with the specified index path.

func scrollToItems(at: Set<IndexPath>, scrollPosition: NSCollectionView.ScrollPosition)

Scrolls the collection view contents until the specified items are visible.