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

# draggingSession(_:sourceOperationMaskFor:)

Declares the types of operations the source allows to be performed.

```
@MainActor func draggingSession(_ session: NSDraggingSession, sourceOperationMaskFor context: NSDraggingContext) -> NSDragOperation
```

## Parameters

`session`

The dragging session.

`context`

The dragging context. See [`NSDraggingContext`](/documentation/AppKit/NSDraggingContext) for the supported values.

## Return Value

A dragging operation you specify.

## Discussion

To account for unexpected contexts, set a `default` case for the most specific context your app handles. The following code shows an example that handles different dragging contexts and includes a default case.

```objc
    switch(context) {
        case NSDraggingContextOutsideApplication:
            return NSDragOperationCopy;
 
        case NSDraggingContextWithinApplication:
        default:
            return NSDragOperationCopy | NSDragOperationMove;
    }
```

---

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)