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

# tryToPerform(_:with:)

Dispatches an action message to the specified target.

```
func tryToPerform(_ action: Selector, with object: Any?) -> Bool
```

## Parameters

`action`

The action message you want to dispatch.

`object`

The target object that defines the specified selector.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if either the receiver or its delegate can accept the specified selector; otherwise, <doc://com.apple.documentation/documentation/Swift/false>. This method also returns <doc://com.apple.documentation/documentation/Swift/false> if `aSelector` is `nil`.

## Discussion

The receiver tries to perform the method `aSelector` using its inherited [`tryToPerform(_:with:)`](/documentation/AppKit/NSResponder/tryToPerform(_:with:)) method of [`NSResponder`](/documentation/AppKit/NSResponder). If the receiver doesn’t perform `aSelector`, the delegate is given the opportunity to perform it using its inherited <doc://com.apple.documentation/documentation/ObjectiveC/NSObjectProtocol/perform(_:with:)> method of <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class>.

## See Also

  <doc://com.apple.documentation/documentation/ObjectiveC/NSObjectProtocol/responds(to:)>



---

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)