---
title: "doCommand(by:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextinputclient/docommand(by:)"
---

# doCommand(by:)

Invokes the action specified by the given selector.

## Declaration

```swift
func doCommand(by selector: Selector)
```

## Parameters

- `selector`: The selector to invoke.

## Discussion

Discussion If selector cannot be invoked, then doCommandBySelector: should not pass this message up the responder chain. NSResponder also implements this method, and it does forward uninvokable commands up the responder chain, but a text view should not. A text view implementing the NSTextInputClient protocol inherits from NSView, which inherits from NSResponder, so your implementation of this method will override the one in NSResponder. It should not call super.

## See Also

### Related Documentation

- [interpretKeyEvents(_:)](appkit/nsresponder/interpretkeyevents(_:).md)
