How to use Picker with optional selection in SwiftUI

Issue #849

We need to explicitly specify optional in tag

extension AVCaptureDevice: Identifiable {
    public var id: String { uniqueID }
}

@State var device: AVCaptureDevice?

Picker("Camera", selection: $device) {
    ForEach(manager.devices) { d in
        Text(d.localizedName)
            .tag(AVCaptureDevice?.some(d))
    }
}
Written by

I’m open source contributor, writer, speaker and product maker.

Start the conversation