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

# shouldReplace(foundTextRange:document:withText:)

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

```
func shouldReplace(foundTextRange: UITextRange, document: Self.DocumentIdentifier?, withText: String) -> Bool
```

## Parameters

`foundTextRange`

The range of characters in a text container to consider a replacement for.

`document`

A string that uniquely identifies the document containing the text range.

`withText`

The string to replace the text with.

## Return Value

Return `No` to prevent the replacement of a particular text range.

## Discussion

Returning `NO` from this method disables the “replace” button in the find panel. If you don’t implement this method, the system assumes all results are replacable.

---

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)