<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCollectionView/deselectAll(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCollectionView(im)deselectAll:"
  },
  "title" : "deselectAll(_:)"
}
-->

# deselectAll(_:)

Deselects all items in the collection view.

```
@IBAction func deselectAll(_ sender: Any?)
```

## Parameters

`sender`

The object that requested the action. You may specify `nil` for this property.

## Discussion

This method works only when the [`isSelectable`](/documentation/AppKit/NSCollectionView/isSelectable) and [`allowsEmptySelection`](/documentation/AppKit/NSCollectionView/allowsEmptySelection) properties are both true  <doc://com.apple.documentation/documentation/Swift/true>. If either property is set to <doc://com.apple.documentation/documentation/Swift/false>, this method quietly does nothing and any connected menu item is disabled.

This method consults the delegate object regarding the selection. Specifically, it calls the delegate’s [`collectionView(_:shouldDeselectItemsAt:)`](/documentation/AppKit/NSCollectionViewDelegate/collectionView(_:shouldDeselectItemsAt:)) method to see if the items should be selected. For any items that are selected, it calls the [`collectionView(_:didDeselectItemsAt:)`](/documentation/AppKit/NSCollectionViewDelegate/collectionView(_:didDeselectItemsAt:)) method.

---

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)