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

# doCommandBySelector:

Invokes the given selector if possible.

```
- (void) doCommandBySelector:(SEL) selector;
```

## Parameters

`selector`

The selector to be invoked.

## Discussion

If `selector` cannot be invoked, then [`doCommandBySelector:`](/documentation/AppKit/NSTextInput/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 [`NSTextInput`](/documentation/AppKit/NSTextInput) 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

[`func interpretKeyEvents([NSEvent])`](/documentation/AppKit/NSResponder/interpretKeyEvents(_:))

Handles a series of key events.



---

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)