Home > AI > IOS > SwiftUI >

SwiftUI wrapped property comparison

namecommondifference
@StateObject1) the variable comforms to ObservableObject
2) get reset when app relaunch
1) will exists even if the view using the @StateObject gets destructed.
@EnvironmentObject1) the variable comforms to ObservableObject
2) get reset when app relaunch
1) global
@ObservedObject1) the variable comforms to ObservableObject
2) get reset when app relaunch
1) will not exists when the view using @ObservedObject gets destructed.
@SceneStorage
@AppStorage1) wrap UserDefaults1) will not reset when app relaunch
2) reset when app reinstall

Leave a Reply