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

# textShouldEndEditing(_:)

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

```
@MainActor optional func textShouldEndEditing(_ textObject: NSText) -> Bool
```

## Discussion

If the delegate returns <doc://com.apple.documentation/documentation/Swift/true>, the text object proceeds to finish editing and resign first responder status. If the delegate returns <doc://com.apple.documentation/documentation/Swift/false>, the text object selects all of its text and remains the first responder.

## See Also

[`func resignFirstResponder() -> Bool`](/documentation/AppKit/NSResponder/resignFirstResponder())

Notifies the receiver that it’s been asked to relinquish its status as first responder in its window.



---

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)