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

# NSSwitch

A control that offers a binary choice.

```
class NSSwitch
```

## Overview

The [`NSSwitch`](/documentation/AppKit/NSSwitch) class provides a simple interface for displaying and toggling a Boolean state, such as on/off. A switch toggles its [`state`](/documentation/AppKit/NSSwitch/state) and sends its [`action`](/documentation/AppKit/NSControl/action) when clicked, activated through the keyboard, or tapped in the Touch Bar. [`NSSwitch`](/documentation/AppKit/NSSwitch) also allows dragging between states, and if [`isContinuous`](/documentation/AppKit/NSControl/isContinuous) is <doc://com.apple.documentation/documentation/Swift/true>, the switch sends its [`action`](/documentation/AppKit/NSControl/action) for each change in position during the drag.

[`NSSwitch`](/documentation/AppKit/NSSwitch) doesn’t use an instance of [`NSCell`](/documentation/AppKit/NSCell) to provide its functionality. The [`cellClass`](/documentation/AppKit/NSControl/cellClass) class property and [`cell`](/documentation/AppKit/NSControl/cell) instance property both return <doc://com.apple.documentation/documentation/ObjectiveC/nil-227m0>, and they ignore attempts to set a non-<doc://com.apple.documentation/documentation/ObjectiveC/nil-227m0> value.

For design guidance, see Human Interface Guidelines > <doc://com.apple.documentation/design/Human-Interface-Guidelines/toggles>.

## Topics

### Managing Switch State

[`state`](/documentation/AppKit/NSSwitch/state)

The current position of the switch.

## Relationships

### Conforms To

[`NSDraggingDestination`](/documentation/AppKit/NSDraggingDestination)

[`NSUserInterfaceItemIdentification`](/documentation/AppKit/NSUserInterfaceItemIdentification)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`Sendable`](/documentation/Swift/Sendable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSAccessibilityButton`](/documentation/AppKit/NSAccessibilityButton)

[`NSAccessibilityProtocol`](/documentation/AppKit/NSAccessibilityProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`NSAccessibilityElementProtocol`](/documentation/AppKit/NSAccessibilityElementProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSAppearanceCustomization`](/documentation/AppKit/NSAppearanceCustomization)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSTouchBarProvider`](/documentation/AppKit/NSTouchBarProvider)

[`NSAnimatablePropertyContainer`](/documentation/AppKit/NSAnimatablePropertyContainer)

[`NSUserActivityRestoring`](/documentation/AppKit/NSUserActivityRestoring)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSStandardKeyBindingResponding`](/documentation/AppKit/NSStandardKeyBindingResponding)

[`NSAccessibilitySwitch`](/documentation/AppKit/NSAccessibilitySwitch)

### Inherits From

[`NSControl`](/documentation/AppKit/NSControl)

---

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)