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

# textShouldEndEditing(_:)

Performs validation on the text field’s new value.

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

## Parameters

`textObject`

The text object that requests permission to end editing.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the new value is valid; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

This method validates the text field’s new value using the `NSCell` method [`isEntryAcceptable:`](/documentation/AppKit/NSCell/isEntryAcceptable:). If the new value is valid and the delegate responds to [`control(_:textShouldEndEditing:)`](/documentation/AppKit/NSControlTextEditingDelegate/control(_:textShouldEndEditing:)), this method invokes that method and returns the result. If the delegate returns <doc://com.apple.documentation/documentation/Swift/false>, the system beeps to indicate that the text field can’t validate the text. See [`NSControl`](/documentation/AppKit/NSControl) for more information about the text delegate method.

---

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)