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

# setDraggingFrame(_:contents:)

Sets the item’s dragging frame and contents.

```
func setDraggingFrame(_ frame: NSRect, contents: Any?)
```

## Parameters

`frame`

The item content frame, which is in the same coordinate space as the value of [`draggingFrame`](/documentation/AppKit/NSDraggingItem/draggingFrame).

`contents`

The item contents to display when dragging. Typically this is an `NSImage`, but a `CGImageRef` will also work.

## Discussion

Alternate single image component setter.

This convenience method simplifies modifying the components of an `NSDraggingItem` when there is only one component. It sets the [`draggingFrame`](/documentation/AppKit/NSDraggingItem/draggingFrame) and creates a single [`NSDraggingImageComponent`](/documentation/AppKit/NSDraggingImageComponent) instance with one image corresponding to the [`icon`](/documentation/AppKit/NSDraggingItem/ImageComponentKey/icon) key. You should use this method only under the following conditions: the drag image for this item is composed of a single image, or there are a reasonable number of dragging item instances being created or enumerated.

If your application requires the dragging of hundreds of items this method would create a instance for each item when it is called. Compare this to the [`imageComponentsProvider`](/documentation/AppKit/NSDraggingItem/imageComponentsProvider) block which is much faster to define and allows AppKit to create only a subset of the items using [`imageComponentsProvider`](/documentation/AppKit/NSDraggingItem/imageComponentsProvider).

This method sets the [`draggingFrame`](/documentation/AppKit/NSDraggingItem/draggingFrame) and [`imageComponents`](/documentation/AppKit/NSDraggingItem/imageComponents) properties.

## See Also

[`imageComponentsProvider`](/documentation/AppKit/NSDraggingItem/imageComponentsProvider)

An array of blocks that provide the dragging image components.



---

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)