Post

Replies

Boosts

Views

Activity

Comment on What is the proper way to instantiate an observable ViewModel with init parameters in a SwiftUI View?
On your example, the line where you'd pass the parameter to the view model is missing. Can you clarify? Because if you try to instantiate the view model and assign it to the StateObject during the init, it fails because the variable when annotated with StateObject is get-only.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’22