---
title: "setSelected(_:at:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstoolbaritemgroup/setselected(_:at:)"
---

# setSelected(_:at:)

Sets the selected state of a subitem in a grouped toolbar item.

## Declaration

```swift
func setSelected(_ selected: Bool, at index: Int)
```

## Parameters

- `selected`: If true, indicates whether to select a subitem, false otherwise.
- `index`: The index location of the subitem.

## See Also

### Working with subitems

- [subitems](appkit/nstoolbaritemgroup/subitems.md)
- [selectedIndex](appkit/nstoolbaritemgroup/selectedindex.md)
- [isSelected(at:)](appkit/nstoolbaritemgroup/isselected(at:).md)
