---
title: "doCommandBySelector:"
framework: AppKit
role: symbol
role_heading: Instance Method
platforms: [macOS 10.0+]
path: "appkit/nstextinput/docommandbyselector:"
---

# doCommandBySelector:

Invokes the given selector if possible.

## Declaration

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

## Parameters

- `selector`: The selector to be invoked.

## 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 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

### Related Documentation

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

### Deprecated methods

- [hasMarkedText](appkit/nstextinput/hasmarkedtext.md)
- [markedRange](appkit/nstextinput/markedrange.md)
- [selectedRange](appkit/nstextinput/selectedrange.md)
- [setMarkedText:selectedRange:](appkit/nstextinput/setmarkedtext:selectedrange:.md)
- [unmarkText](appkit/nstextinput/unmarktext.md)
- [validAttributesForMarkedText](appkit/nstextinput/validattributesformarkedtext.md)
- [attributedSubstringFromRange:](appkit/nstextinput/attributedsubstringfromrange:.md)
- [insertText:](appkit/nstextinput/inserttext:.md)
- [characterIndexForPoint:](appkit/nstextinput/characterindexforpoint:.md)
- [firstRectForCharacterRange:](appkit/nstextinput/firstrectforcharacterrange:.md)
- [conversationIdentifier](appkit/nstextinput/conversationidentifier.md)
