<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextAttachment/init(fileWrapper:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextAttachment(im)initWithFileWrapper:"
  },
  "title" : "init(fileWrapper:)"
}
-->

# init(fileWrapper:)

Creates a text attachment object to contain the specified file wrapper.

```
convenience init(fileWrapper: FileWrapper?)
```

## Parameters

`fileWrapper`

The file wrapper for the attachment.

## Return Value

A new text attachment object initialized with the file wrapper.

## Discussion

This method is the designated initializer for the [`NSTextAttachment`](/documentation/AppKit/NSTextAttachment) class in macOS.

If `aWrapper` contains an image file that the receiver can interpret as an [`NSImage`](/documentation/AppKit/NSImage) object, this method sets the attachment cell’s image to that image rather than to the icon of `aWrapper`.

---

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)