---
title: "tryToPerform(_:with:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsresponder/trytoperform(_:with:)"
---

# tryToPerform(_:with:)

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

## Declaration

```swift
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

Return Value Returns false if no responder is found that responds to action; otherwise, true.

## Discussion

Discussion If the receiver responds to action, it invokes the method with object as the argument and returns true. If the receiver doesn’t respond, it sends this message to its next responder with the same selector and object.

## See Also

### Related Documentation

- [sendAction(_:to:from:)](appkit/nsapplication/sendaction(_:to:from:).md)
