Add an option to require multiple items for UIDocumentBrowserAction

Number:rdar://42856290 Date Originated:02-Aug-2018 05:01 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:11.4.1 & 12b5
Classification:Enhancement Reproducible:Always
Currently there is no way to add a UIDocumentBrowserAction that requires multiple items to be selected when adding an action to UIDocumentBrowserViewController’s customActions. 

A similar property, which enabled UIDocumentBrowserAction to handle multiple items, in addition to a single item, is already publicly available with supportsMultipleItems. Although there is no option to disable the action for a single selected item with the currently available API.

A workaround that can be used is enabling supportsMultipleItems and show an error to the user if only one item has been selected. This is rather semi-optimal since the action advertises itself to be working fine with only one selected item, and the user loses their selected item when the UIDocumentBrowserAction is executed, therefore they need to select the item again for executing the action again.

I propose adding `var requiresMultipleItems: Bool` to UIDocumentBrowserAction, restricting its usage to multiple selected items, and being deactivated when only a single item is selected.

One example where this property would be useful: Merging PDFs from the document browser. There is no logic that could be executed if only a single item is selected. This feature always requires multiple items to be selected. This feature is implemented in PDF Viewer, with the above described workaround in place.

This only applies to actions with the UIDocumentBrowserAction.Availability .navigationBar, since .menu doesn’t support handling multiple items at all.

Steps to Reproduce:
- Create a UIDocumentBrowserAction (with the availability .navigationBar), whose logic only applies to working with multiple items.
- Add the action to UIDocumentBrowserViewController.customActions.
- Select a single item in the document browser.
- See that the action is enabled, with no way to disable it.

Expected Results:
An option that enables requiring UIDocumentBrowserAction to only operate with multiple items.

Actual Results:
No option that enables requiring UIDocumentBrowserAction to only operate with multiple items.

11.4.1 & 12b5



Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!