---
title: "write(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspasteboard/write(_:)"
---

# write(_:)

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

## Declaration

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

## Parameters

- `wrapper`: The file wrapper to write to the pasteboard.

## Return Value

Return Value true if the data was successfully written, otherwise false.

## Discussion

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.

## See Also

### Writing data (macOS 10.5 and earlier)

- [declareTypes(_:owner:)](appkit/nspasteboard/declaretypes(_:owner:).md)
- [addTypes(_:owner:)](appkit/nspasteboard/addtypes(_:owner:).md)
- [writeFileContents(_:)](appkit/nspasteboard/writefilecontents(_:).md)
