<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSToolbarItemGroup/selectedIndex",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSToolbarItemGroup(py)selectedIndex"
  },
  "title" : "selectedIndex"
}
-->

# selectedIndex

The index value for the most recently selected subitem of a grouped toolbar item.

```
var selectedIndex: Int { get set }
```

## Discussion

When using the [`NSToolbarItemGroup.SelectionMode.selectAny`](/documentation/AppKit/NSToolbarItemGroup/SelectionMode-swift.enum/selectAny) or [`NSToolbarItemGroup.SelectionMode.momentary`](/documentation/AppKit/NSToolbarItemGroup/SelectionMode-swift.enum/momentary) selection mode, don’t assume that this value represents the selected subitem. This method returns the index of the most recently selected subitem.

To determine if a specific subitem of a grouped toolbar item is selected, use the [`isSelected(at:)`](/documentation/AppKit/NSToolbarItemGroup/isSelected(at:)) 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)