name | common | difference |
---|---|---|
@StateObject | 1) the variable comforms to ObservableObject 2) get reset when app relaunch | 1) will exists even if the view using the @StateObject gets destructed. |
@EnvironmentObject | 1) the variable comforms to ObservableObject 2) get reset when app relaunch | 1) global |
@ObservedObject | 1) the variable comforms to ObservableObject 2) get reset when app relaunch | 1) will not exists when the view using @ObservedObject gets destructed. |
@SceneStorage | ||
@AppStorage | 1) wrap UserDefaults | 1) will not reset when app relaunch 2) reset when app reinstall |