<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextLayoutManager/replaceContents(in:with:)-2elb",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextLayoutManager(im)replaceContentsInRange:withAttributedString:"
  },
  "title" : "replaceContents(in:with:)"
}
-->

# replaceContents(in:with:)

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

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

---

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)