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

# setSelectionIndexPaths(_:)

Sets the tree controller’s current selection to the specified index paths.

```
func setSelectionIndexPaths(_ indexPaths: [IndexPath]) -> Bool
```

## Parameters

`indexPaths`

An array of <doc://com.apple.documentation/documentation/Foundation/NSIndexPath> objects specifying the selected objects.

## Return Value

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

## Discussion

Attempting to change the selection may cause a `commitEditing` message which fails, thus denying the selection change.

---

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)