---
title: "init(attachment:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsattributedstring/init(attachment:)"
---

# init(attachment:)

Creates an attributed string with an attachment.

## Declaration

```swift
init(attachment: NSTextAttachment)
```

## Parameters

- `attachment`: The attrachment to place in the string.

## Return Value

Return Value An attributed string containing the attachment.

## Discussion

Discussion This is a convenience method for creating an attributed string containing an attachment using character as the base character.

## See Also

### Creating a string with an attachment

- [init(attachment:attributes:)](foundation/nsattributedstring/init(attachment:attributes:).md)
- [init(adaptiveImageGlyph:attributes:)](foundation/nsattributedstring/init(adaptiveimageglyph:attributes:).md)
