Post

Replies

Boosts

Views

Activity

ItemIdentifiers when selecting multiple photos with PhotosPicker
The problem: In iOS 16.2, selecting multiple photos with PhotosPicker does not seem to allow me to access the selected photos' local identifiers. More accurately, the attribute itemItentifier is alway nil. In a single-selection mode, the itemIdentifier populates normally. Example I am selecting multiple photos with PhotosPicker as follows: .photosPicker(isPresented: $showMultiplePhotoPicker, selection: $photoSelections, matching: .images, photoLibrary: .shared() ) and then observing changes in photoSelections as follows: .onChange(of: photoSelections) { _ in for selection in photoSelections { print("Selection: \(selection)") print("Item identifier: \(selection.itemIdentifier)") What gets printed in the console: Selection: PhotosPickerItem(_itemIdentifier: Optional("B84E8479-475C-4727-A4A4-B77AA9980897/L0/001"), _shouldExposeItemIdentifier: false, _supportedContentTypes: [<_UTCoreType 0x1b9bdda00> public.jpeg (not dynamic, declared)], _itemProvider: <PUPhotosFileProviderItemProvider: 0x60000112c090> {types = ( "public.jpeg" )}) Item identifier: nil So while the PhotosPickerItem has a value for _itemIdentifier, it's replaced by nil when accessing it via .itemIdentifier. The culprit here, I think, is _shouldExposeItemIdentifier: false: this value is true in a single-selection mode. Any thought on this would be highly appreciated!
1
0
1k
Apr ’23
ItemIdentifiers when selecting multiple photos with PhotosPicker
The problem: In iOS 16.2, selecting multiple photos with PhotosPicker does not seem to allow me to access the selected photos' local identifiers. More accurately, the attribute itemItentifier is alway nil. In a single-selection mode, the itemIdentifier populates normally. Example I am selecting multiple photos with PhotosPicker as follows: .photosPicker(isPresented: $showMultiplePhotoPicker, selection: $photoSelections, matching: .images, photoLibrary: .shared() ) and then observing changes in photoSelections as follows: .onChange(of: photoSelections) { _ in for selection in photoSelections { print("Selection: \(selection)") print("Item identifier: \(selection.itemIdentifier)") What gets printed in the console: Selection: PhotosPickerItem(_itemIdentifier: Optional("B84E8479-475C-4727-A4A4-B77AA9980897/L0/001"), _shouldExposeItemIdentifier: false, _supportedContentTypes: [<_UTCoreType 0x1b9bdda00> public.jpeg (not dynamic, declared)], _itemProvider: <PUPhotosFileProviderItemProvider: 0x60000112c090> {types = ( "public.jpeg" )}) Item identifier: nil So while the PhotosPickerItem has a value for _itemIdentifier, it's replaced by nil when accessing it via .itemIdentifier. The culprit here, I think, is _shouldExposeItemIdentifier: false: this value is true in a single-selection mode. Any thought on this would be highly appreciated!
Replies
1
Boosts
0
Views
1k
Activity
Apr ’23