---
title: "sendAction(_:to:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscontrol/sendaction(_:to:)"
---

# sendAction(_:to:)

Causes the specified action to be sent to the target.

## Declaration

```swift
func sendAction(_ action: Selector?, to target: Any?) -> Bool
```

## Parameters

- `action`: The selector to invoke on the target. If the selector is NULL, no message is sent.
- `target`: The target object to receive the message. If the object is nil, the application searches the responder chain for an object capable of handling the message. For more information on dispatching actions, see the class description for doc://com.apple.appkit/documentation/AppKit/NSActionCell.

## Return Value

Return Value true if the message was successfully sent; otherwise, false.

## Discussion

Discussion This method uses the sendAction(_:to:from:) method of NSApplication to invoke the specified method on an object. The receiver is passed as the parameter to the action message. This method is invoked primarily by the  trackMouse(with:in:of:untilMouseUp:) method of NSCell.

## See Also

### Implementing the Target-Action Mechanism

- [action](appkit/nscontrol/action.md)
- [target](appkit/nscontrol/target.md)
- [isContinuous](appkit/nscontrol/iscontinuous.md)
- [sendAction(on:)](appkit/nscontrol/sendaction(on:).md)
