---
title: "collectionView(_:writeItemsAt:to:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscollectionviewdelegate/collectionview(_:writeitemsat:to:)-23ozm"
---

# collectionView(_:writeItemsAt:to:)

Places the data for the drag operation on the pasteboard.

## Declaration

```swift
optional func collectionView(_ collectionView: NSCollectionView, writeItemsAt indexPaths: Set<IndexPath>, to pasteboard: NSPasteboard) -> Bool
```

## Parameters

- `collectionView`: The collection view making the request.
- `indexPaths`: The index paths of the items being dragged.
- `pasteboard`: The pasteboard on which to place the drag data.

## Return Value

Return Value true if the drag operation can continue or false if you want to refuse the drag.

## Discussion

Discussion You must implement this method or the collectionView(_:pasteboardWriterForItemAt:) method to support drag operations. The collection view calls the collectionView(_:pasteboardWriterForItemAt:) method in preference to this one if both are implemented. If your app supports multi-image drag and drop, you must implement the collectionView(_:pasteboardWriterForItemAt:) method. The collection view calls this method after it has determined that a drag should begin but before the drag operation has started.  Your implementation of this method should do the following: Declare the pasteboard types you support using the declareTypes(_:owner:) method of the provided pasteboard object. Write data to the pasteboard for each type you declare. Return true from this method.

## See Also

### Drag and Drop Support

- [Supporting Collection View Drag and Drop Through File Promises](appkit/supporting-collection-view-drag-and-drop-through-file-promises.md)
- [collectionView(_:canDragItemsAt:with:)](appkit/nscollectionviewdelegate/collectionview(_:candragitemsat:with:)-49wix.md)
- [collectionView(_:pasteboardWriterForItemAt:)](appkit/nscollectionviewdelegate/collectionview(_:pasteboardwriterforitemat:)-5eyyl.md)
- [collectionView(_:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAt:)](appkit/nscollectionviewdelegate/collectionview(_:namesofpromisedfilesdroppedatdestination:fordraggeditemsat:)-6yag4.md)
- [collectionView(_:draggingImageForItemsAt:with:offset:)](appkit/nscollectionviewdelegate/collectionview(_:draggingimageforitemsat:with:offset:)-898js.md)
- [collectionView(_:draggingSession:willBeginAt:forItemsAt:)](appkit/nscollectionviewdelegate/collectionview(_:draggingsession:willbeginat:foritemsat:)-68x2y.md)
- [collectionView(_:draggingSession:endedAt:dragOperation:)](appkit/nscollectionviewdelegate/collectionview(_:draggingsession:endedat:dragoperation:).md)
- [collectionView(_:updateDraggingItemsForDrag:)](appkit/nscollectionviewdelegate/collectionview(_:updatedraggingitemsfordrag:).md)
- [collectionView(_:validateDrop:proposedIndexPath:dropOperation:)](appkit/nscollectionviewdelegate/collectionview(_:validatedrop:proposedindexpath:dropoperation:).md)
- [collectionView(_:acceptDrop:indexPath:dropOperation:)](appkit/nscollectionviewdelegate/collectionview(_:acceptdrop:indexpath:dropoperation:).md)
