<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextSearching-3wkjv",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:5UIKit15UITextSearchingP"
  },
  "title" : "UITextSearching"
}
-->

# UITextSearching

The methods you use on a find session’s searchable objects to perform search operations and decorate the found text results.

```
protocol UITextSearching : NSObjectProtocol
```

## Overview

Implement this protocol on the class that encapsulates the searchable content for your view. This allows you to use an instance of [`UITextSearchingFindSession`](/documentation/UIKit/UITextSearchingFindSession) to manage the session for a find interaction.

## Topics

### Handling searches

[`performTextSearch(queryString:options:resultAggregator:)`](/documentation/UIKit/UITextSearching-3wkjv/performTextSearch(queryString:options:resultAggregator:))

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

[`UITextSearchAggregator`](/documentation/UIKit/UITextSearchAggregator-swift.struct)

The methods you use on a find session’s aggregator to collect matching text ranges for a search.

[`compare(_:toRange:document:)`](/documentation/UIKit/UITextSearching-3wkjv/compare(_:toRange:document:))

Compares ranges from the set of matches the aggregator provides to determine navigation order.

[`compare(document:toDocument:)`](/documentation/UIKit/UITextSearching-3wkjv/compare(document:toDocument:))

Compares documents containing matching ranges from the set the aggregator provides to determine navigation order.

[`DocumentIdentifier`](/documentation/UIKit/UITextSearching-3wkjv/DocumentIdentifier)

An object that uniquely identifies a specific document when searching for matching text across multiple documents.

### Displaying results

[`decorate(foundTextRange:document:usingStyle:)`](/documentation/UIKit/UITextSearching-3wkjv/decorate(foundTextRange:document:usingStyle:))

Applies the style to a specific text range to indicate found and highlighted results.

[`clearAllDecoratedFoundText()`](/documentation/UIKit/UITextSearching-3wkjv/clearAllDecoratedFoundText())

Clears the style from all found and highlighted results.

[`willHighlight(foundTextRange:document:)`](/documentation/UIKit/UITextSearching-3wkjv/willHighlight(foundTextRange:document:))

Informs the searchable object when the highlighted search result is about to change.

[`scrollRangeToVisible(_:inDocument:)`](/documentation/UIKit/UITextSearching-3wkjv/scrollRangeToVisible(_:inDocument:))

Scrolls to the containing view to make the text range visible.

### Identifying selected text

[`selectedTextRange`](/documentation/UIKit/UITextSearching-3wkjv/selectedTextRange)

The range of selected text in a document.

[`selectedTextSearchDocument`](/documentation/UIKit/UITextSearching-3wkjv/selectedTextSearchDocument)

The object that uniquely identifies the specific document with selected text.

### Handling replacements

[`supportsTextReplacement`](/documentation/UIKit/UITextSearching-3wkjv/supportsTextReplacement)

A Boolean value that indicates whether the searchable object supports replacing text.

[`replace(foundTextRange:document:withText:)`](/documentation/UIKit/UITextSearching-3wkjv/replace(foundTextRange:document:withText:))

Informs the searchable object to replace the text range for the highlighted search result.

[`replaceAll(queryString:options:withText:)`](/documentation/UIKit/UITextSearching-3wkjv/replaceAll(queryString:options:withText:))

Informs the searchable object to replace all matching text across all searchable documents.

[`shouldReplace(foundTextRange:document:withText:)`](/documentation/UIKit/UITextSearching-3wkjv/shouldReplace(foundTextRange:document:withText:))

Determines whether the searchable object allows replacement of the text range you provide.



---

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)