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

# sendAction(_:to:from:)

Sends the given action message to the given target.

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

## Parameters

`action`

The action message you want to send.

`target`

The target object that defines the specified action message.

`sender`

The object to pass for the action message’s parameter.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the action was successfully sent; otherwise <doc://com.apple.documentation/documentation/Swift/false>. This method also returns <doc://com.apple.documentation/documentation/Swift/false> if `anAction` is `nil`.

## Discussion

If `aTarget` is `nil`, [`shared`](/documentation/AppKit/NSApplication/shared) looks for an object that can respond to the message—that is, an object that implements a method matching `anAction`. It begins with the first responder of the key window. If the first responder can’t respond, it tries the first responder’s next responder and continues following next responder links up the responder chain. If none of the objects in the key window’s responder chain can handle the message, [`shared`](/documentation/AppKit/NSApplication/shared) attempts to send the message to the key window’s delegate.

If the delegate doesn’t respond and the main window is different from the key window, [`shared`](/documentation/AppKit/NSApplication/shared) begins again with the first responder in the main window. If objects in the main window can’t respond, [`shared`](/documentation/AppKit/NSApplication/shared) attempts to send the message to the main window’s delegate. If still no object has responded, [`shared`](/documentation/AppKit/NSApplication/shared) tries to handle the message itself. If [`shared`](/documentation/AppKit/NSApplication/shared) can’t respond, it attempts to send the message to its own delegate.

## See Also

[`makeWindowsPerform(_:inOrder:)`](/documentation/AppKit/NSApplication/makeWindowsPerform(_:inOrder:))

Sends the specified message to each of the app’s window objects until one returns a non-`nil` value.



---

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)