Saving images in array in the same order in which it is selected using PHPickerViewController

Apple Recommended

Replies

Yes.

  • Create the array, empty
  • append the image to the array each time you pick an image.
  • It does not work for multiple selections of images.

  • You're right. You may either force single pick and reopen picker immediately, removing the already selected images, until user Cancels. In case of multiple selection, how are you "sure" that user will pick them in order ? He/she could change his mind and unselect and select a new one. Which order would you consider ?

Add a Comment

All we have to work with is the PHPickerViewControllerDelegate, which gives us the single method:
• picker(_:didFinishPicking:)

This passes us:
• results: [PHPickerResult]

...and we can look at this, to get an array of NSItemProvider, then get our images.

However, there is no information on what order was used, when picking the items.

So what you want to achieve is not possible with PHPickerViewController.

You would have to create your own (more advanced version of) PHPickerViewController.

Post marked as downvoted Up vote reply of robnotyou Down vote reply of robnotyou
Post marked as solved
  • It's possible to get selected assets based on the user selection order.

Add a Comment