<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextViewDelegate/textView(_:write:at:to:type:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextViewDelegate(im)textView:writeCell:atIndex:toPasteboard:type:"
  },
  "title" : "textView(_:write:at:to:type:)"
}
-->

# textView(_:write:at:to:type:)

Returns whether data of the specified type for the given cell could be written to the specified pasteboard.

```
@MainActor optional func textView(_ view: NSTextView, write cell: any NSTextAttachmentCellProtocol, at charIndex: Int, to pboard: NSPasteboard, type: NSPasteboard.PasteboardType) -> Bool
```

## Parameters

`view`

The text view sending the message.

`cell`

The cell whose contents should be written to the pasteboard.

`charIndex`

The index at which the cell was accessed.

`pboard`

The pasteboard to which the cell’s contents should be written.

`type`

The type of data that should be written.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the write succeeded, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

The receiver should attempt to write the `cell` to `pboard` with the given `type`, and return success or failure.

---

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)