Instance Method


Incorporates the dropped content into the collection view.


optional func collectionView(_ collectionView: NSCollectionView, acceptDrop draggingInfo: NSDraggingInfo, indexPath: IndexPath, dropOperation: NSCollectionView.DropOperation) -> Bool



The collection view receiving the dropped content.


The information about the drag operation.


The index path at which the drop occurred. Use this location as the insertion point for the content.


The type of drop operation to perform.

Return Value

true if the drop operation should be accepted or false if it should be rejected.


The collection view calls this method when the user releases the mouse button while it is over a valid drop target. This method is called after the collectionView(_:validateDrop:proposedIndexPath:dropOperation:) method validates that dropping the content at the specified location is possible. You must implement this method to accept the dropped content and incorporate it into the collection view.

In your implementation, use the information in the draggingInfo parameter to retrieve the data, update your data source object, and insert the appropriate items into the collection view. The dropped data is stored in the draggingPasteboard property of the dragging information object.

If the animatesToDestination property of the dragging information is true, update the image and frame for each dragged item to its new location in the collection view. You can enumerate the list of dragged items using the enumerateDraggingItems(options:for:classes:searchOptions:using:) method of the dragging information object.

See Also

Drag and Drop Support

func collectionView(NSCollectionView, canDragItemsAt: Set<IndexPath>, with: NSEvent) -> Bool

Returns a Boolean indicating whether a drag operation involving the specified items can begin.

func collectionView(NSCollectionView, pasteboardWriterForItemAt: IndexPath) -> NSPasteboardWriting?

Provides the pasteboard writer for the item at the specified index path.

func collectionView(NSCollectionView, writeItemsAt: Set<IndexPath>, to: NSPasteboard) -> Bool

Places the data for the drag operation on the pasteboard.

func collectionView(NSCollectionView, namesOfPromisedFilesDroppedAtDestination: URL, forDraggedItemsAt: Set<IndexPath>) -> [String]

Returns the names of the promised files that you created for a drag operation.

func collectionView(NSCollectionView, updateDraggingItemsForDrag: NSDraggingInfo)

Asks your delegate to update the dragging items during a drag operation.