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

# tryToPerform(_:with:)

Attempts to perform the method indicated by an action with a specified argument.

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

## Parameters

`action`

The selector identifying the action method.

`object`

The object to use as the sole argument of the action method.

## Return Value

Returns <doc://com.apple.documentation/documentation/Swift/false> if no responder is found that responds to `action;` otherwise, <doc://com.apple.documentation/documentation/Swift/true>.

## Discussion

If the receiver responds to `action`, it invokes the method with `object` as the argument and returns <doc://com.apple.documentation/documentation/Swift/true>. If the receiver doesn’t respond, it sends this message to its next responder with the same selector and object.

## See Also

[`sendAction(_:to:from:)`](/documentation/AppKit/NSApplication/sendAction(_:to:from:))

Sends the given action message to the given target.



---

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)