Fixer of explicitly unwrapped optionals

SwiftUI.List selection is not working as expected in Beta 5

Added on by Paul Wood.

So a List can have selected items in it in SwiftUI. However Zoe Smith found an issue with them if you need to have the list preselected and provided to the SwiftUI framework via a BindableObject. The following Script is mostly working, but after some really simple changes the selection no longer works.

At first Glance I thought everything was fine, A the item I selected because it was first, selected all fine. I thought that was that.

Screen+Shot+2019-08-18+at+8.48.36+PM.jpg

Zoe changed the Selected Item from A to C and no longer saw a selection on first load

Screen+Shot+2019-08-18+at+8.48.48+PM.jpg

Tap A though and you got both items visible

Screen+Shot+2019-08-18+at+8.51.39+PM.jpg

I tried to go above and beyond to model something that I consider to be most normal in an Application, and ObservableObject holding @Published arrays and sets to Reference Types. However nothing worked as expected in this setup, not even the editing mode!

Screen+Shot+2019-08-18+at+8.46.13+PM.jpg

So if you are using List selection in SwiftUI in the Beta, I hope this is a warning to what is currently possible and if this bothers you please file a Feedback to Apple about it, I already have, and Zoe will too!