<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSPasteboard/write(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPasteboard(im)writeFileWrapper:"
  },
  "title" : "write(_:)"
}
-->

# write(_:)

Writes the serialized contents of the specified file wrapper to the pasteboard.

```
func write(_ wrapper: FileWrapper) -> Bool
```

## Parameters

`wrapper`

The file wrapper to write to the pasteboard.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the data was successfully written, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

Writes the serialized contents of the file wrapper `wrapper` to the receiver and declares the data to be of type `NSFileContentsPboardType` and also of a type appropriate for the file’s extension (as returned by the `NSCreateFileContentsPboardType` function when passed the files extension), if it has one. If `wrapper` does not have a preferred filename, this method raises an exception.

---

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)