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

# setEnabled(_:forSegment:)

Sets the enabled state of the specified segment

```
func setEnabled(_ enabled: Bool, forSegment segment: Int)
```

## Parameters

`enabled`

<doc://com.apple.documentation/documentation/Swift/true> to enable the segment; otherwise, <doc://com.apple.documentation/documentation/Swift/false> to disable it.

`segment`

The index of the segment you want to enable or disable. This method raises an exception (<doc://com.apple.documentation/documentation/Foundation/NSExceptionName/rangeException>) if the index is out of bounds.

---

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)