<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UICollectionViewDelegate/collectionView(_:performPrimaryActionForItemAt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UICollectionViewDelegate(im)collectionView:performPrimaryActionForItemAtIndexPath:"
  },
  "title" : "collectionView(_:performPrimaryActionForItemAt:)"
}
-->

# collectionView(_:performPrimaryActionForItemAt:)

Tells the delegate to perform the primary action for the cell at the specified index path.

```
optional func collectionView(_ collectionView: UICollectionView, performPrimaryActionForItemAt indexPath: IndexPath)
```

## Parameters

`collectionView`

The collection view object on which to perform the primary action.

`indexPath`

The index path of the cell.

## Discussion

Primary actions allow you to distinguish between a distinct user action and a change in selection (like a focus change or other indirect selection change). A primary action occurs when a person selects a single cell without extending an existing selection.

UIKit calls this method after [`collectionView(_:shouldSelectItemAt:)`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldSelectItemAt:)) and [`collectionView(_:didSelectItemAt:)`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didSelectItemAt:)), regardless of whether the cell selection state changes. Use [`collectionView(_:didSelectItemAt:)`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:didSelectItemAt:)) to update the state of the current view controller (like its buttons, title, and so on), and use [`collectionView(_:performPrimaryActionForItemAt:)`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:performPrimaryActionForItemAt:)) for actions like navigation or showing another split view column.

If [`collectionView(_:shouldSelectItemAt:)`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldSelectItemAt:)) returns <doc://com.apple.documentation/documentation/Swift/true> to allow selection for the cell at `indexPath`, only that cell has selection when the system calls this method. If [`collectionView(_:shouldSelectItemAt:)`](/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldSelectItemAt:)) returns <doc://com.apple.documentation/documentation/Swift/false>, the system preserves the existing cell selection in the collection view. You can use this behavior to perform primary actions on nonselectable, button-style cells without changing the selection.

---

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)