---
title: "replaceContents(in:with:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nstextlayoutmanager/replacecontents(in:with:)-80j0b"
---

# replaceContents(in:with:)

Replaces content at the location you specify with the text elements string you provide.

## Declaration

```swift
func replaceContents(in range: NSTextRange, with textElements: [NSTextElement])
```

## Parameters

- `range`: The range of the content to replace.
- `textElements`: An array of text elements.

## See Also

### Accessing the text storage

- [textContentManager](uikit/nstextlayoutmanager/textcontentmanager.md)
- [textContainer](uikit/nstextlayoutmanager/textcontainer.md)
- [textSelectionNavigation](uikit/nstextlayoutmanager/textselectionnavigation.md)
- [textSelections](uikit/nstextlayoutmanager/textselections.md)
- [usageBoundsForTextContainer](uikit/nstextlayoutmanager/usageboundsfortextcontainer.md)
- [enumerateTextSegments(in:type:options:using:)](uikit/nstextlayoutmanager/enumeratetextsegments(in:type:options:using:).md)
- [replace(_:)](uikit/nstextlayoutmanager/replace(_:).md)
- [replaceContents(in:with:)](uikit/nstextlayoutmanager/replacecontents(in:with:)-2elb.md)
