<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextSearching-53wjq/replaceFoundTextInRange:inDocument:withText:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITextSearching(im)replaceFoundTextInRange:inDocument:withText:"
  },
  "title" : "replaceFoundTextInRange:inDocument:withText:"
}
-->

# replaceFoundTextInRange:inDocument:withText:

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

```
- (void) replaceFoundTextInRange:(UITextRange *) range inDocument:(UITextSearchDocumentIdentifier) document withText:(NSString *) replacementText;
```

## Parameters

`range`

The text range to replace.

`document`

A string that uniquely identifies a document when searching multiple documents, or `nil` when searching a single document.

`replacementText`

The string to replace the text with.

## Discussion

When [`supportsTextReplacement`](/documentation/UIKit/UITextSearching-53wjq/supportsTextReplacement) returns `YES,` the system calls this method during a find session to request a text range to replace.

---

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)