<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIFindSession",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIFindSession"
  },
  "title" : "UIFindSession"
}
-->

# UIFindSession

An abstract base class that manages the state, presentation, and behavior for a search that the find interaction initiates.

```
@MainActor class UIFindSession
```

## Overview

You return a session object from the delegate of a [`UIFindInteraction`](/documentation/UIKit/UIFindInteraction) to manage the state, presentation, and behavior for a given search. The session object responds to navigation and replacement requests through its [`highlightNextResult(in:)`](/documentation/UIKit/UIFindSession/highlightNextResult(in:)) and [`performSingleReplacement(query:replacementString:options:)`](/documentation/UIKit/UIFindSession/performSingleReplacement(query:replacementString:options:)) methods. It also provides presentation information to the system find panel through [`resultCount`](/documentation/UIKit/UIFindSession/resultCount) and [`highlightedResultIndex`](/documentation/UIKit/UIFindSession/highlightedResultIndex).

UIKit can manage the state when you implement the [`UITextSearching`](/documentation/UIKit/UITextSearching-53wjq) protocol on a class that encapsulates the searchable content. To do this, create an instance of [`UITextSearchingFindSession`](/documentation/UIKit/UITextSearchingFindSession) and provide it a [`searchableObject`](/documentation/UIKit/UITextSearchingFindSession/searchableObject) using an instance of your class.

If you want to manage the state yourself or already have a class that implements find and replace for your app, you can subclass [`UIFindSession`](/documentation/UIKit/UIFindSession) to bridge your custom implementation to the system UI.

## Topics

### Getting session information

[`resultCount`](/documentation/UIKit/UIFindSession/resultCount)

The total number of results the search matches.

[`highlightedResultIndex`](/documentation/UIKit/UIFindSession/highlightedResultIndex)

The index of the result the find panel highlights.

[`supportsReplacement`](/documentation/UIKit/UIFindSession/supportsReplacement)

A Boolean value that indicates whether to allow replacing find panel results.

[`allowsReplacementForCurrentlyHighlightedResult`](/documentation/UIKit/UIFindSession/allowsReplacementForCurrentlyHighlightedResult)

A Boolean value that indicates whether to allow replacing the result the find panel is highlighting.

[`searchResultDisplayStyle`](/documentation/UIKit/UIFindSession/searchResultDisplayStyle-swift.property)

The information the find panel includes in the summary of found results.

[`UIFindSession.SearchResultDisplayStyle`](/documentation/UIKit/UIFindSession/SearchResultDisplayStyle-swift.enum)

Constants that describe the results summary the find panel UI includes.

### Managing session interactions

[`performSearch(query:options:)`](/documentation/UIKit/UIFindSession/performSearch(query:options:))

Initiates a search for the query string you provide.

[`performSingleReplacement(query:replacementString:options:)`](/documentation/UIKit/UIFindSession/performSingleReplacement(query:replacementString:options:))

Replaces a single instance of the query string with the replacement string you provide.

[`replaceAll(searchQuery:replacementString:options:)`](/documentation/UIKit/UIFindSession/replaceAll(searchQuery:replacementString:options:))

Replaces all matching instances of the query string with the replacement string you provide.

[`highlightNextResult(in:)`](/documentation/UIKit/UIFindSession/highlightNextResult(in:))

Updates the highlighted result to the next or previous match.

[`invalidateFoundResults()`](/documentation/UIKit/UIFindSession/invalidateFoundResults())

Invalidates the found ranges and updates the system find panel.

### Deprecated

[`allowsReplacement`](/documentation/UIKit/UIFindSession/allowsReplacement)

A Boolean value that indicates whether to allow replacing the result the find panel is highlighting.



---

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)