Instance Method


Invoked after it has been determined that a drag should begin, but before the drag has been started.


optional func collectionView(_ collectionView: NSCollectionView, writeItemsAt indexes: IndexSet, to pasteboard: NSPasteboard) -> Bool



The collection view that send the message.


The indexes of the items to write to the pasteboard.


The pasteboard containing the content from the dragged items.

Return Value

true to begin the drag, otherwise false.


To start the drag, you must first declare the pasteboard types that are supported by sending pasteboard a declareTypes(_:owner:) method. You then place the data for the items at the specified indexes on pasteboard, and return true from the method.

The drag image and other drag related information will be set up and provided by the view once this call returns true.

You need to implement this method for your collection view to be a drag source.

See Also