<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTableViewDataSource/tableView(_:draggingSession:willBeginAt:forRowIndexes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTableViewDataSource(im)tableView:draggingSession:willBeginAtPoint:forRowIndexes:"
  },
  "title" : "tableView(_:draggingSession:willBeginAt:forRowIndexes:)"
}
-->

# tableView(_:draggingSession:willBeginAt:forRowIndexes:)

Implement this method to determine when a dragging session will begin.

```
@MainActor optional func tableView(_ tableView: NSTableView, draggingSession session: NSDraggingSession, willBeginAt screenPoint: NSPoint, forRowIndexes rowIndexes: IndexSet)
```

## Parameters

`tableView`

The table view.

`session`

The dragging session.

`screenPoint`

The initial drag location in screen coordinates.

`rowIndexes`

The indexes of the rows to be dragged, excluding rows that were not dragged due to [`tableView(_:pasteboardWriterForRow:)`](/documentation/AppKit/NSTableViewDataSource/tableView(_:pasteboardWriterForRow:)) returning `nil`.

## Discussion

Implement this method to know when the dragging session is about to begin and to potentially modify the dragging session.

The dragged item order will directly match the pasteboard writer array used to begin the dragging session with the `NSView` method [`beginDraggingSession(with:event:source:)`](/documentation/AppKit/NSView/beginDraggingSession(with:event:source:)). Hence, the order is deterministic, and can be used in [`tableView(_:acceptDrop:row:dropOperation:)`](/documentation/AppKit/NSTableViewDataSource/tableView(_:acceptDrop:row:dropOperation:)) when enumerating the [`NSDraggingInfo`](/documentation/AppKit/NSDraggingInfo) pasteboard classes.

---

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)