<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/beginDraggingSession(items:gesture:source:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(im)beginDraggingSessionWithItems:gesture:source:"
  },
  "title" : "beginDraggingSession(items:gesture:source:)"
}
-->

# beginDraggingSession(items:gesture:source:)

Initiates a drag operation using a gesture recognizer.

```
func beginDraggingSession(items: [NSDraggingItem], gesture: NSGestureRecognizer, source: any NSDraggingSource) -> NSDraggingSession?
```

## Parameters

`items`

The dragging items. The frame property of each [`NSDraggingItem`](/documentation/AppKit/NSDraggingItem) must be in the view’s coordinate system.

`gesture`

The gesture recognizer initiating the drag session.

`source`

An object that controls the dragging operation and conforms to the [`NSDraggingSource`](/documentation/AppKit/NSDraggingSource) protocol.

## Return Value

The dragging session for the drag, or `nil` if the method can’t start the session.

## Discussion

Like [`beginDraggingSession(with:event:source:)`](/documentation/AppKit/NSView/beginDraggingSession(with:event:source:)), this method starts an internal tracking loop. If the gesture is mouse-based, the system cancels the gesture at the end of the drag-and-drop operation. If the gesture is touch-based, the system cancels the gesture at the start of the drag-and-drop operation.

The system may animate drag images from their initial positions into a system-defined formation. The system clips the drag to the visible area of the view.

```swift
var dragSession: NSDraggingSession?

@objc func handleDragGesture(_ gestureRecognizer: NSGestureRecognizer) {
    if gestureRecognizer.state == .began {
        let items = [NSDraggingItem(pasteboardWriter: myPasteboardItem)]
        
        // Returns nil if the drag fails to start.
        dragSession = self.beginDraggingSession(items: items, gesture: gestureRecognizer, source: self)
    }
}
```

## See Also

[`-  beginDraggingSessionWithItems:event:source:`](/documentation/AppKit/NSView/beginDraggingSession(with:event:source:))

Initiates a dragging session with a group of dragging items.



---

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)