---
title: "performValidatedReplacement(in:with:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextview/performvalidatedreplacement(in:with:)"
---

# performValidatedReplacement(in:with:)

Replaces text in the range you specify with the attributed string you provide.

## Declaration

```swift
func performValidatedReplacement(in range: NSRange, with attributedString: NSAttributedString) -> Bool
```

## Parameters

- `range`: The range of the replacement.
- `attributedString`: The attributed string to use as the replacement text.

## Return Value

Return Value Retuns true if the replacement was successful, false otherwise.

## See Also

### Checking and substituting text

- [checkTextInDocument(_:)](appkit/nstextview/checktextindocument(_:).md)
- [checkTextInSelection(_:)](appkit/nstextview/checktextinselection(_:).md)
- [checkText(in:types:options:)](appkit/nstextview/checktext(in:types:options:).md)
- [handleTextCheckingResults(_:forRange:types:options:orthography:wordCount:)](appkit/nstextview/handletextcheckingresults(_:forrange:types:options:orthography:wordcount:).md)
- [enabledTextCheckingTypes](appkit/nstextview/enabledtextcheckingtypes.md)
- [isAutomaticDashSubstitutionEnabled](appkit/nstextview/isautomaticdashsubstitutionenabled.md)
- [toggleAutomaticDashSubstitution(_:)](appkit/nstextview/toggleautomaticdashsubstitution(_:).md)
- [isAutomaticDataDetectionEnabled](appkit/nstextview/isautomaticdatadetectionenabled.md)
- [toggleAutomaticDataDetection(_:)](appkit/nstextview/toggleautomaticdatadetection(_:).md)
- [isAutomaticSpellingCorrectionEnabled](appkit/nstextview/isautomaticspellingcorrectionenabled.md)
- [toggleAutomaticSpellingCorrection(_:)](appkit/nstextview/toggleautomaticspellingcorrection(_:).md)
- [isAutomaticTextReplacementEnabled](appkit/nstextview/isautomatictextreplacementenabled.md)
- [toggleAutomaticTextReplacement(_:)](appkit/nstextview/toggleautomatictextreplacement(_:).md)
