<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextInput/shouldChangeText(in:replacementText:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITextInput(im)shouldChangeTextInRange:replacementText:"
  },
  "title" : "shouldChangeText(in:replacementText:)"
}
-->

# shouldChangeText(in:replacementText:)

Asks whether to replace the text in the specified range.

```
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

<doc://com.apple.documentation/documentation/Swift/true> if the text should be changed or <doc://com.apple.documentation/documentation/Swift/false> if it should not.

## 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 <doc://com.apple.documentation/documentation/Swift/true>.

---

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)