How to handle PhotosPicker selected changed msg?

@State private var selectedItems:[PhotosPickerItem] = [] {
        didSet {
            print("items changed.")
        }
    }
...
               PhotosPicker(
                    selection: $selectedItems,
                    matching: .images,
                ) {
                    Text("select pictures")
                }

I want to know selectedItem changed, but didSet of selectedItems is not work.

Is there any other way to inform me: Has the user selected some pictures?

I want to create a task to load picture and display them to view after user selected some picture.

Thank you.

Answered by Tomato in 889937022

Isn't it just the matter of using the onChange(of:initial:_:) modifier?

Accepted Answer

Isn't it just the matter of using the onChange(of:initial:_:) modifier?

How to handle PhotosPicker selected changed msg?
 
 
Q