---
title: "replaceContents(in:with:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextlayoutmanager/replacecontents(in:with:)-2elb"
---

# replaceContents(in:with:)

Replaces content at the location you specify with an attributed string you provide.

## Declaration

```swift
func replaceContents(in range: NSTextRange, with attributedString: NSAttributedString)
```

## Parameters

- `range`: The range of the content to replace.
- `attributedString`: An attribued string to replace the content at range.

## See Also

### Accessing the text storage

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