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

# prepareForDragOperation(_:)

Invoked when the image is released, allowing the receiver to agree to or refuse drag operation.

```
@MainActor optional func prepareForDragOperation(_ sender: any NSDraggingInfo) -> Bool
```

## Parameters

`sender`

The object sending the message; use it to get details about the dragging operation.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the receiver agrees to perform the drag operation and <doc://com.apple.documentation/documentation/Swift/false> if not.

## Discussion

This method is invoked only if the most recent [`draggingEntered(_:)`](/documentation/AppKit/NSDraggingDestination/draggingEntered(_:)) or [`draggingUpdated(_:)`](/documentation/AppKit/NSDraggingDestination/draggingUpdated(_:)) message returned an acceptable drag-operation value.

If you want the drag items to animate from their current location on screen to their final location in your view, set the sender object’s [`animatesToDestination`](/documentation/AppKit/NSDraggingInfo/animatesToDestination) property to <doc://com.apple.documentation/documentation/Swift/true> in your implementation of this method.

---

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)