---
title: "setSelectionIndexPaths(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstreecontroller/setselectionindexpaths(_:)"
---

# setSelectionIndexPaths(_:)

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

## Declaration

```swift
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 Value Return true if the selection has changed, otherwise false.

## Discussion

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

## See Also

### Getting the current selection

- [setSelectionIndexPath(_:)](appkit/nstreecontroller/setselectionindexpath(_:).md)
- [selectionIndexPath](appkit/nstreecontroller/selectionindexpath.md)
- [selectionIndexPaths](appkit/nstreecontroller/selectionindexpaths.md)
- [selectedObjects](appkit/nstreecontroller/selectedobjects.md)
- [selectedNodes](appkit/nstreecontroller/selectednodes.md)
