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

# NSTextSelectionManager

An object that coordinates text selection behavior for custom text views.

```
@MainActor class NSTextSelectionManager
```

## Overview

[`NSTextSelectionManager`](/documentation/AppKit/NSTextSelectionManager) provides a centralized way to manage text selection interactions using a set of gesture recognizers. For keyboard-based selection, integrate [`NSTextSelectionNavigation`](/documentation/AppKit/NSTextSelectionNavigation) with your view. The selection manager works with a delegate to update and respond to selection changes, and with a data source to query the text layout system.

## Topics

### Setting a delegate

[`var delegate: (any NSTextSelectionManager.Delegate)?`](/documentation/AppKit/NSTextSelectionManager/delegate-swift.property)

The delegate of the text selection manager.

[`protocol Delegate`](/documentation/AppKit/NSTextSelectionManager/Delegate-swift.protocol)

A set of methods that manage text selection state and let you customize selection behavior.

### Configuring text selection

[`var textSelectionMode: NSTextSelectionManager.Mode`](/documentation/AppKit/NSTextSelectionManager/textSelectionMode)

The interaction mode for text selection.

[`enum Mode`](/documentation/AppKit/NSTextSelectionManager/Mode)

Values for text selection interaction modes.

[`var textSelectionDataSource: (any NSTextSelectionDataSource)?`](/documentation/AppKit/NSTextSelectionManager/textSelectionDataSource)

The data source that provides text layout information to the selection manager.

### Managing gesture recognizers

[`var gesturesForFailureRequirements: [NSGestureRecognizer]`](/documentation/AppKit/NSTextSelectionManager/gesturesForFailureRequirements)

The gesture recognizers managed by the selection manager.

## Relationships

### Conforms To

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

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

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

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

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

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

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

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)