<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/dragOperation(for:type:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(im)dragOperationForDraggingInfo:type:"
  },
  "title" : "dragOperation(for:type:)"
}
-->

# dragOperation(for:type:)

Returns the type of drag operation that should be performed if the image were released now.

```
func dragOperation(for dragInfo: any NSDraggingInfo, type: NSPasteboard.PasteboardType) -> NSDragOperation
```

## Parameters

`dragInfo`

The drag information.

`type`

The pasteboard type that will be read from the dragging pasteboard.

## Return Value

The drag operation that should be performed if the image were released now.

## Discussion

The returned value should be one of the following:

|Option                  |Meaning                                                                      |
|------------------------|-----------------------------------------------------------------------------|
|`NSDragOperationCopy`   |The data represented by the image will be copied.                            |
|`NSDragOperationLink`   |The data will be shared.                                                     |
|`NSDragOperationGeneric`|The operation will be defined by the destination.                            |
|`NSDragOperationPrivate`|The operation is negotiated privately between the source and the destination.|

If none of the operations is appropriate, this method should return `NSDragOperationNone`.

This method is called repeatedly from [`draggingEntered(_:)`](/documentation/AppKit/NSDraggingDestination/draggingEntered(_:)) and [`draggingUpdated(_:)`](/documentation/AppKit/NSDraggingDestination/draggingUpdated(_:)) as the user drags the image.

## See Also

[`-  draggingUpdated:`](/documentation/AppKit/NSDraggingDestination/draggingUpdated(_:))

Invoked periodically as the image is held within the destination area, allowing modification of the dragging operation or mouse-pointer position.

[`-  draggingEntered:`](/documentation/AppKit/NSDraggingDestination/draggingEntered(_:))

Invoked when the dragged image enters destination bounds or frame; delegate returns dragging operation to perform.



---

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)