Contents

collectionView(_:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAt:)

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

Declaration

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

Parameters

  • collectionView:

    The collection view asking you to provide the list of filenames.

  • dropURL:

    The URL at which to create the promised files.

  • indexPaths:

    The index paths of the dragged items.

Return Value

An array of strings containing the filenames you created, or intend to create, at the specified URL.

Discussion

At the start of a drag operation, your app must provide the data that constitutes the items being dragged. If you specify a file promise, instead of the data itself, use this method to specify the names of the files you promised. If the files already exist, move them to the directory specified by the dropURL parameter. If you must create the files first, use this method to specify the names of the files you intend to provide and begin creating those files asynchronously on a background thread.

The filenames you return are made available from the namesOfPromisedFilesDropped(atDestination:) method of the NSDraggingInfo object passed around during the drag operation.

For more information about how to use file promises when dragging content, see Drag and Drop Programming Topics.

See Also

Drag and Drop Support