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

# NSTextDelegate

A set of optional methods implemented by the delegate of an [`NSText`](/documentation/AppKit/NSText) object to edit text and change text formats.

```
protocol NSTextDelegate : NSObjectProtocol
```

## Topics

### Changing text formatting

[`-  textDidChange:`](/documentation/AppKit/NSTextDelegate/textDidChange(_:))

Informs the delegate that the text object has changed its characters or formatting attributes.

### Editing text

[`-  textShouldBeginEditing:`](/documentation/AppKit/NSTextDelegate/textShouldBeginEditing(_:))

Invoked when a text object begins to change its text, this method requests permission for `aTextObject` to begin editing.

[`-  textDidBeginEditing:`](/documentation/AppKit/NSTextDelegate/textDidBeginEditing(_:))

Informs the delegate that the text object has begun editing (that the user has begun changing it).

[`-  textShouldEndEditing:`](/documentation/AppKit/NSTextDelegate/textShouldEndEditing(_:))

Invoked from a text object’s implementation of [`resignFirstResponder()`](/documentation/AppKit/NSResponder/resignFirstResponder()), this method requests permission for `aTextObject` to end editing.

[`-  textDidEndEditing:`](/documentation/AppKit/NSTextDelegate/textDidEndEditing(_:))

Informs the delegate that the text object has finished editing (that it has resigned first responder status).

## Relationships

### Conforming Types

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

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

### Inherited By

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

### Inherits From

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

---

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)