What is the correct design pattern for initializing SwiftUI view state from a function that can throw an exception?

Thanks for the thoughts @gwendal.roue. I am still thinking through the correct design for the error handling, though am mostly convinced that however I handle it, the best user experience will involve setting some state to indicate the error so the user knows what is going on. Right now I'm conditionally showing an error Text view during prototyping.

What was confusing me about that approach was believing that @State properties were not supposed to be set in an initializer (which would apply to both my original state property and any error state properties) (see post). Based on Jessy's post, I'm going to try setting both properties in the initializer and see how it goes.

1 Like