<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextSearching-3wkjv/performTextSearch(queryString:options:resultAggregator:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:5UIKit15UITextSearchingP17performTextSearch11queryString7options16resultAggregatorySS_So0bF7OptionsCAA0bfK0Vy18DocumentIdentifierQzGtF"
  },
  "title" : "performTextSearch(queryString:options:resultAggregator:)"
}
-->

# performTextSearch(queryString:options:resultAggregator:)

Searches for ranges of text matching the string across all searchable documents and collects results in the aggregator.

```
func performTextSearch(queryString: String, options: UITextSearchOptions, resultAggregator: UITextSearchAggregator<Self.DocumentIdentifier>)
```

## Parameters

`queryString`

The string to search for.

`options`

The configurable options to use for matching words and comparing strings.

`resultAggregator`

An object you use to collect matching results. The aggregator is thread-safe, so you may send it messages on other threads.

## Discussion

The system calls this method during a find session to perform the search. Your implenentation should search for matching text ranges in your app’s documents and call [`foundRange(_:searchString:document:)`](/documentation/UIKit/UITextSearchAggregator-swift.struct/foundRange(_:searchString:document:)) on the aggregator object to add them to the set of matching ranges.

---

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)