Post

Replies

Boosts

Views

Activity

Reply to observing an AppStorage object across multiple views
I'm experiencing the same issue with using @AppStorage inside of a class that conforms to ObservableObject. I, too, would love to know what is going on here and if this is a bug or we're doing something wrong. In the meantime, my hacky solution was to create a second variable inside my ObservableObject that is initialized with UserDefaults and that is published manually and once set, updates the @AppStorage variable. Roughly, like this... @AppStorage("value") var userValue: String = "Tahu!" var value = UserDefaults.standard.string(forKey: "value") ?? "" {     didSet {         userValue = value     } willSet {         objectWillChange.send()  	 } } Am I missing something about how @AppStorage works? Or is it just not fully working yet in the beta?
Jun ’20