Search code examples
swiftswiftuiproperty-wrapper

Where to use @StateObject and ObservableObject?


I'm learning swiftUI and I'm getting confused in @StateObject and @ObservableObject when to use them and where to use them.


Solution

  • See Apple's Managing Model Data in Your App. ObservedObject comes from a parent view and StateObject instantiates in the View that needs it.