0

I have been unable to find enough documentation to get started on a Photos Project extension (available in High Sierra).

How do I retrieve what a user has selected (like how Apple does it with their Prints extension), and display that in my extension's view?

Dale Townsend
  • 671
  • 3
  • 13
  • 25

1 Answers1

2

I think you just want to look at PHProjectInfo which is passed to you in beginProject. That's where you get the real context of what was selected. For example:

let sections = projectInfo.sections
guard let firstContentSection = sections.first(where: { section in    section.sectionType == .content }),
let firstContents = firstContentSection.sectionContents.first

You then need to convert the cloud identifiers to local ones for fetching:

localIdentifiers = context.photoLibrary.localIdentifiers(for: cloudIdentifiers)

From there, you can fetch the actual PHAssets:

let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: localIdentifiers, options: nil)

For any PHAsset, when you want the image you want to use PHImageManager:

imageManager.requestImage(for: asset, targetSize: targetSize, contentMode: PHImageContentMode.aspectFit, options: nil)
Brent
  • 46
  • 4