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

# performAction(_:)

Performs the specified text finding action.

```
func performAction(_ op: NSTextFinder.Action)
```

## Parameters

`op`

The text finding action. See [`NSTextFinder.Action`](/documentation/AppKit/NSTextFinder/Action) for the possible values.

## Discussion

Objects that respond to [`performTextFinderAction(_:)`](/documentation/AppKit/NSResponder/performTextFinderAction(_:)) typically call [`validateAction(_:)`](/documentation/AppKit/NSTextFinder/validateAction(_:)) to ensure that the action is valid and then invoke [`performAction(_:)`](/documentation/AppKit/NSTextFinder/performAction(_:)) if validation is successful.

When invoking the [`validateAction(_:)`](/documentation/AppKit/NSTextFinder/validateAction(_:)) and [`performAction(_:)`](/documentation/AppKit/NSTextFinder/performAction(_:)) the item or sender’s tag should be passed as the parameter. By convention, the `sender` parameter for this method will have an [`NSTextFinder.Action`](/documentation/AppKit/NSTextFinder/Action) set as its tag. The responder that receives this method should pass the tag as the action for this method:

```objc
- (void)performTextFinderAction:(id)sender {
    [self.textFinder performAction:[sender tag]];
}
```

---

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)