Instance Method


Validates whether a drop operation is possible at the specified location.


- (NSDragOperation)collectionView:(NSCollectionView *)collectionView validateDrop:(id<NSDraggingInfo>)draggingInfo proposedIndexPath:(NSIndexPath * _Nonnull *)proposedDropIndexPath dropOperation:(NSCollectionViewDropOperation *)proposedDropOperation;



The collection view asking you to validate the drop operation.


The information about the drag operation.


The index path at which the drop would occur. This parameter is passed by-reference and can be modified to change the proposed index path.


The type of drop operation being proposed. This parameter is passed by-reference and can be modified to change the drop operation type.

Return Value

A value that indicates which dragging operation to perform. Return NSDragOperationNone to disallow a drop at the proposed location.


Although implementation of this method is optional, you must implement it to support drops onto the associated collection view. You must also call the collection view’s registerForDraggedTypes: method to register the types of drops it supports. If you do not perform both of these actions, the collection view does not accept drops.

When an interactive drag operation occurs, the collection view calls this method to determine whether the current mouse location is a valid place to drop the content. This method may be called many times during the course of the drag operation. Your implementation should look at the proposed location and return a constant that reflects how the drop would be handled.

While validating the drop location, you can suggest a better drop location by updating the values in the proposedDropIndexPath and proposedDropOperation parameters. For example, you might suggest dropping the content before the specified item instead of on it. The collection view sets the proposedDropOperation parameter to NSCollectionViewDropOn when the mouse is closer to the middle of an item than to its edges; otherwise, it sets the parameter to NSCollectionViewDropBefore.

See Also

Drag and Drop Support

- collectionView:canDragItemsAtIndexPaths:withEvent:

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

- collectionView:pasteboardWriterForItemAtIndexPath:

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

- collectionView:writeItemsAtIndexPaths:toPasteboard:

Places the data for the drag operation on the pasteboard.

- collectionView:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAtIndexPaths:

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

- collectionView:draggingImageForItemsAtIndexPaths:withEvent:offset:

Creates and returns a drag image to represent the specified items during a drag.

- collectionView:draggingSession:willBeginAtPoint:forItemsAtIndexPaths:

Notifies your delegate that a drag session is about to begin.

- collectionView:draggingSession:endedAtPoint:dragOperation:

Notifies your delegate that a drag session ended.

- collectionView:updateDraggingItemsForDrag:

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

- collectionView:acceptDrop:indexPath:dropOperation:

Incorporates the dropped content into the collection view.