---
title: "init(containerSize:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nstextcontainer/init(containersize:)"
---

# init(containerSize:)

Initializes a text container with a specified bounding rectangle.

## Declaration

```swift
convenience init(containerSize aContainerSize: NSSize)
```

## Parameters

- `aContainerSize`: The size of the text container’s bounding rectangle.

## Return Value

Return Value The newly initialized text container.

## Discussion

Discussion The new text container must be added to an NSLayoutManager object before it can be used. The text container must also have an NSTextView object set for text to be displayed. This method is the designated initializer for the NSTextContainer class.

## See Also

### Deprecated

- [lineFragmentRect(forProposedRect:sweepDirection:movementDirection:remaining:)](appkit/nstextcontainer/linefragmentrect(forproposedrect:sweepdirection:movementdirection:remaining:).md)
- [contains(_:)](appkit/nstextcontainer/contains(_:).md)
- [containerSize](appkit/nstextcontainer/containersize.md)
