Skip to content

PHPickerResult ​

PHPickerResult represents one item the user picked in the photo picker. It appears only in the results of the pick event.

It isn't an image itself. Its itemProvider is the provider of this item's content, and the image is loaded from the provider.

You need to install @nacrejs/photos first; for how, see PHPickerViewController, or see Core and capability packages.

Inheritance: NSObject → PHPickerResult

Constructor ​

It can't be created with new. new PHPickerResult() throws TypeError:

Illegal constructor: PHPickerResult is created by the runtime, not by new

Instance properties ​

PropertyDescription
itemProvider read-onlyThe provider of this item's content

Examples ​

js
const picker = new PHPickerViewController(new PHPickerConfiguration());
picker.addEventListener('pick', async (event) => {
  const { results } = /** @type {PHPickerViewControllerFinishEvent} */ (event);
  picker.dismissViewController({ animated: true });
  for (const result of results) {
    const image = await result.itemProvider.loadObjectOfClass(UIImage);
    console.log(image.size.width, image.size.height);
  }
});

Effect: After the user finishes picking, one line with the width and height (in points) is printed for each picked image. Not verified in the simulator.

Corresponding iOS API ​

ObjCJS
result.itemProviderresult.itemProvider

See also ​