The error is due to the macro for @Observable converting prop0 to be a computed property. One alternative is this:
@Observable
final class Model {
var prop0: Int {
didSet {
guard oldValue != self.prop0 else { return }
UserDefaults.standard.set(self.prop0, forKey: "prop0")
}
}
private init() {
prop0 = UserDefaults.standard.integer(forKey: "prop0")
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: