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

# init(attachment:attributes:)

Creates an attributed string with an attachment and applies the specified attributes to it.

## Declaration

```swift
convenience init(attachment: NSTextAttachment, attributes: [NSAttributedString.Key : Any] = [:])
```

## Parameters

- `attachment`: The attrachment to place in the string.
- `attributes`: The attributes to apply to the attachment. Specify an empty dictionary to create the string without any extra attributes.

## Return Value

Return Value An attributed string containing the attachment.

## See Also

### Creating a string with an attachment

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