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

# setSelectionIndexes(_:)

Sets the receiver’s selection indexes and returns a Boolean value that indicates whether the selection changed.

```
func setSelectionIndexes(_ indexes: IndexSet) -> Bool
```

## Parameters

`indexes`

The set of selection indexes for the receiver.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the selection was changed, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

Attempting to change the selection may cause a [`commitEditing()`](/documentation/AppKit/NSController/commitEditing()) message which fails, thus denying the selection change.

To select all the receiver’s objects, indexes should be an index set with indexes `[0...count -1]`. To deselect all indexes, pass an empty index set.

---

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)