---
title: "replace(_:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nstextlayoutmanager/replace(_:)"
---

# replace(_:)

Replaces the current text content manager with a new one you provide.

## Declaration

```swift
func replace(_ textContentManager: NSTextContentManager)
```

## Parameters

- `textContentManager`: The new text context manager.

## Discussion

Discussion Use this method to replace the current NSTextContentManager with a new one, leaving all related objects intact. This method makes sure the NSTextLayoutManager doesn’t get deallocated while migrating to the new manager.

## 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)
- [replaceContents(in:with:)](uikit/nstextlayoutmanager/replacecontents(in:with:)-2elb.md)
- [replaceContents(in:with:)](uikit/nstextlayoutmanager/replacecontents(in:with:)-80j0b.md)
