Hi, guys. In Xcode Beta 4, the PhotosPicker view doesn't modify the state property when all the items are deselected. This seems to be a bug, but I don't know how to file a bug for a beta API.
This code generates a list with the selected pictures. If you select a picture and then deselect it, the item is not removed from the list.
import SwiftUI
import PhotosUI
struct ContentView: View {
@State private var selected: [PhotosPickerItem] = []
var body: some View {
NavigationStack {
List(selected, id: \.itemIdentifier) { item in
Text(item.itemIdentifier ?? "")
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
PhotosPicker(selection: $selected, matching: .images, photoLibrary: .shared()) { Text("Select Photos") }
}
}
}
}
}