<!--
{
  "availability" : [
    "macOS: 10.4.0 - 10.15.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTableViewDataSource/tableView(_:writeRowsWith:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTableViewDataSource(im)tableView:writeRowsWithIndexes:toPasteboard:"
  },
  "title" : "tableView(_:writeRowsWith:to:)"
}
-->

# tableView(_:writeRowsWith:to:)

Returns a Boolean value that indicates whether a drag operation is allowed.

```
optional func tableView(_ tableView: NSTableView, writeRowsWith rowIndexes: IndexSet, to pboard: NSPasteboard) -> Bool
```

## Parameters

`tableView`

The table view that sent the message.

`rowIndexes`

An index set of row numbers that will be participating in the drag.

`pboard`

The pasteboard to which to write the drag data.

## Return Value

`YES` if the drag operation is allowed, `NO` otherwise.

## Discussion

Called by `aTableView` after it has been determined that a drag should begin, but before the drag has been started.

To refuse the drag, return <doc://com.apple.documentation/documentation/Swift/false>. To start a drag, return <doc://com.apple.documentation/documentation/Swift/true> and place the drag data onto `pboard` (data, owner, and so on). The drag image and other drag-related information will be set up and provided by the table view once this call returns with <doc://com.apple.documentation/documentation/Swift/true>.

---

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)