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

# textDidEndEditing(_:)

Posts a notification when the text is no longer in edit mode.

```
func textDidEndEditing(_ notification: Notification)
```

## Parameters

`notification`

The [`textDidEndEditingNotification`](/documentation/AppKit/NSControl/textDidEndEditingNotification) to post to the default notification center.

## Discussion

After validating the new value, this method posts a [`textDidEndEditingNotification`](/documentation/AppKit/NSControl/textDidEndEditingNotification) to the default notification center, which causes the text field’s delegate to receive a <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/controlTextDidEndEditing:> message. This method then sends [`endEditing(_:)`](/documentation/AppKit/NSCell/endEditing(_:)) to the text field’s cell and handles the key that causes editing to end as follows:

- If the user ends editing by pressing Return, this method tries to send the text field’s action to its target. If unsuccessful, it sends [`performKeyEquivalent(with:)`](/documentation/AppKit/NSView/performKeyEquivalent(with:)) to its `NSView`, for example, to handle the default button on a panel. If that also fails, the text field selects its text.
- If the user ends editing by pressing Tab or Shift-Tab, the text field tries to have its `NSWindow` object select its next or previous key view, using the `NSWindow` method [`selectKeyView(following:)`](/documentation/AppKit/NSWindow/selectKeyView(following:)) or [`selectKeyView(preceding:)`](/documentation/AppKit/NSWindow/selectKeyView(preceding:)). If unsuccessful, the text field selects its 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)