Guilherme Delgado
11/08/2021, 11:30 AM@StateObject private var postListViewModel = ViewModels().postListViewModel().asStateObject()
The state is accessed in the screens through a Combineobservable object.@Published
@ObservedObject private var postListViewModel = ViewModels().postListViewModel().asObservableObject()
🤔Tip: It is really important that you useonly with views that were passed in from elsewhere. You should not use this property wrapper to create the initial instance of an observable object – that’s what@ObservedObject
is for.@StateObject
Remember, please do not useis it because of this last sentence?to create instances of your object. If that’s what you want to do, use@ObservedObject
instead.@StateObject
kenkyee
11/08/2021, 12:11 PM