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

# selectText(_:)

Ends editing in the text field and, if it’s selectable, selects the entire text content.

```
func selectText(_ sender: Any?)
```

## Parameters

`sender`

The sender of the message.

## Discussion

If the text field isn’t in a window’s view hierarchy, this method has no effect.

---

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)