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

# replaceLayoutManager(_:)

Replaces the layout manager for the group of text system objects that contains the text container.

```
func replaceLayoutManager(_ newLayoutManager: NSLayoutManager)
```

## Parameters

`newLayoutManager`

The new layout manager.

## Discussion

The framework reassigns all text containers and text views attached to the old layout manager to the new layout manager. Unlike setting the [`layoutManager`](/documentation/AppKit/NSTextContainer/layoutManager) property directly, this method makes all the adjustments necessary to keep the text object relationships intact.

---

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)