<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSegmentedCell/selectedSegment",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSegmentedCell(py)selectedSegment"
  },
  "title" : "selectedSegment"
}
-->

# selectedSegment

The index of the selected segment of the control, or `-1` if no segment is selected.

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

## Discussion

This property contains the zero-based index of the segment. If the control allows multiple selections, the value of this property is the index of the most recently selected segment.

If you specify an index that is out of bounds, an exception (<doc://com.apple.documentation/documentation/Foundation/NSExceptionName/rangeException>) is raised.

---

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)