<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManager/replaceTextStorage(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutManager(im)replaceTextStorage:"
  },
  "title" : "replaceTextStorage(_:)"
}
-->

# replaceTextStorage(_:)

Replaces the layout manager’s current text storage object with the specified object.

```
func replaceTextStorage(_ newTextStorage: NSTextStorage)
```

## Parameters

`newTextStorage`

The text storage object to set.

## Discussion

Use this method to update the text storage uniformly for a group of related layout manager objects. Unlike changing the value in the textStorage property, this method replaces the text storage for all [`NSLayoutManager`](/documentation/AppKit/NSLayoutManager) objects that share the current layout manager’s [`NSTextStorage`](/documentation/AppKit/NSTextStorage) object.

---

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)