Problem Statement
Explain the differences between `@StateObject`, `@ObservedObject` and `@EnvironmentObject` in SwiftUI, and how you decide which to use in view architecture.
Explanation
In SwiftUI `@StateObject` is used when a view *creates and owns* an instance of a reference-type model (`ObservableObject`) and you want it to persist for the view’s lifetime. `@ObservedObject` is used when the view *receives* a reference to a model created elsewhere; the view doesn’t own it but observes changes. `@EnvironmentObject` is used when you place a shared model in the environment so many descendant views can access it, and it must be injected. /n/n Choosing between them depends on ownership and lifecycle: use `@StateObject` for root-level creation, `@ObservedObject` for child views receiving models, and `@EnvironmentObject` when data is truly shared across many views. Understanding these distinctions shows strong SwiftUI architecture knowledge.