---
title: "shouldReplace(foundTextRange:document:withText:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextsearching-3wkjv/shouldreplace(foundtextrange:document:withtext:)"
---

# shouldReplace(foundTextRange:document:withText:)

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

## Declaration

```swift
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 Value Return No to prevent the replacement of a particular text range.

## Discussion

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.

## See Also

### Handling replacements

- [supportsTextReplacement](uikit/uitextsearching-3wkjv/supportstextreplacement.md)
- [replace(foundTextRange:document:withText:)](uikit/uitextsearching-3wkjv/replace(foundtextrange:document:withtext:).md)
- [replaceAll(queryString:options:withText:)](uikit/uitextsearching-3wkjv/replaceall(querystring:options:withtext:).md)
