---
title: "shouldChangeText(in:replacementText:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextinput/shouldchangetext(in:replacementtext:)"
---

# shouldChangeText(in:replacementText:)

Asks whether to replace the text in the specified range.

## Declaration

```swift
optional func shouldChangeText(in range: UITextRange, replacementText text: String) -> Bool
```

## Parameters

- `range`: A range of text in a document.
- `text`: The proposed text to replace the text in range.

## Return Value

Return Value true if the text should be changed or false if it should not.

## Discussion

Discussion Prior to replacing text, this method is called to give your delegate a chance to accept or reject the edits. If you do not implement this method, the return value defaults to true.

## See Also

### Replacing and returning text

- [text(in:)](uikit/uitextinput/text(in:).md)
- [replace(_:withText:)](uikit/uitextinput/replace(_:withtext:).md)
