Post

Replies

Boosts

Views

Activity

Comment on Why is @Binding not behaving as I expect here?
@Binding is not the right property wrapper to declare an ObservableObject inside a View. Use @ObservedObject or @StateObject to do that. @Binding is used for value type variables. Can you elaborate here? A struct is a value type? Or are you referring to my definition of final class StateProvider: ObservableObject {} and usage of $stateProvider.data? I think it would be a serious design limitation if we couldn't use a binding on an observable object, no?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22