---
title: "collectionView(_:didSelectItemsAt:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscollectionviewdelegate/collectionview(_:didselectitemsat:)"
---

# collectionView(_:didSelectItemsAt:)

Notifies the delegate object that one or more items were selected.

## Declaration

```swift
@MainActor optional func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>)
```

## Parameters

- `collectionView`: The collection view notifying you of the selection change.
- `indexPaths`: The set of doc://com.apple.documentation/documentation/Foundation/NSIndexPath objects corresponding to the items that are now selected.

## Discussion

Discussion After the user successfully selects one or more items, the collection view calls this method to let you know that the selection has been made. Use this method to respond to the selection change and to make any necessary adjustments to your content or the collection view. This method is not called when you set the selection programmatically using the methods of the NSCollectionView class.

## See Also

### Managing the Selection

- [collectionView(_:shouldSelectItemsAt:)](appkit/nscollectionviewdelegate/collectionview(_:shouldselectitemsat:).md)
- [collectionView(_:shouldDeselectItemsAt:)](appkit/nscollectionviewdelegate/collectionview(_:shoulddeselectitemsat:).md)
- [collectionView(_:didDeselectItemsAt:)](appkit/nscollectionviewdelegate/collectionview(_:diddeselectitemsat:).md)
