UIDragItem should allow to specify a count for items to be dropped

Originator:oscar
Number:rdar://41790438 Date Originated:03-Jul-2018 03:53 PM
Status:Open Resolved:Duplicate of 41811293
Product:iOS + SDK Product Version:11.4
Classification:Enhancement Reproducible:Always
 
Summary:
In our application, we allow users to import PDF documents via the iOS 11 Drag & Drop APIs.

The suite of Drag & Drop APIs, however, assumes that every drop item in a drop session represents one "unit" to be dropped in the given view. 

This is not always true. For instance, when importing a PDF into our application, even though the drop item it's correctly represented as a single URL on disk, the assumption that we'd like only one item dropped in our view is not correct, as a PDF document inflated from a given URL can (and almost always will) have more than just one page.

I think it would be really useful for the Drag & Drop APIs to provide a way to tell the receiver of the drop that the drop item can represent more than one "unit".

This could either be achieved at the UIDragItem level with some API like this:

```
let dragItem = [[UIDragItem alloc] initWithItemProvider:provider];
dragItem.representedNumberOfItems = 3 // This drag item represents 3 units (PDF document with 3 pages)
```

Then, the drop coordinators could take the information out of that item and, for instance, insert the correct number of placeholders on the collection view/table view. Since the `dropItem:toPlaceholder:` method already returns a placeholder context, removing/updating all placeholders at once would be relatively easy as well.

I'm not certain, but it seems like this kind of API could be useful at the NSItemProvider level as well.

Our current solution for this issue is to always remove the placeholder that inserted with the drop coordinator, and then manually add the appropriate index paths for the pages that were just added to the document. 

Steps to Reproduce:
Implement Drag & Drop APIs and try to make an informed decision about how many "units" an actual drag item represents.

Expected Results:
There's a way to specify the "unit" count per drag item so that the drops can be handled more easily.

Actual Results:
There's no way to know how many items an actual drag item represents.

Version:
11.4

Notes:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!