in iOS13 I do the following to bind my View to my model:
class MyModel: ObservableObject {
@Published var someVar: String = "initial value"
}
struct MyView: View {
@ObservedObject var model = MyModel()
var body: some View {
Text("the value is \(model.someVar)")
}
}
in iOS14 there is a new property wrapper called @StateObject that I can use in the place of @ObservedObject, I need this snippet of code to be compatible with iOS13 and iOS14 while leveraging iOS14's new feature, how can I do that with @StateObject for the same variable ?