---
title: "@StateObject vs. @ObservedObject: The differences explained"
url: https://daily.dev/posts/stateobject-vs-observedobject-the-differences-explained-m59jsolm0
source_url: https://www.avanderlee.com/swiftui/stateobject-observedobject-differences
type: article
source: "SwiftLee"
published: 2026-08-24T14:05:40.130Z
updated: 2026-08-24T14:06:02.620Z
tags: ["ios", "swift", "swiftui"]
reading_time: 6
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# @StateObject vs. @ObservedObject: The differences explained

**[SwiftLee](https://daily.dev/sources/avanderlee)** · 6 min read · 0 upvotes · 0 comments

## Summary

Explains the difference between SwiftUI's @StateObject and @ObservedObject property wrappers: use @StateObject when a view creates and owns an ObservableObject, and @ObservedObject when the view receives one from a parent. Covers common pitfalls like creating an object inline with @ObservedObject, which causes it to reset when SwiftUI recreates the view. Also touches on the newer Observation framework (@Observable and @State) as the recommended approach for iOS 17+ projects, while noting @StateObject/@ObservedObject remain relevant for older OS support or existing ObservableObject models.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.avanderlee.com/swiftui/stateobject-observedobject-differences>

## Questions this post answers

### When should I use @StateObject versus @ObservedObject in SwiftUI?

Use @StateObject when the view creates and owns the ObservableObject, and @ObservedObject when the view receives the object from a parent. Only @StateObject preserves the object's lifetime across view updates; creating an object inline with @ObservedObject causes SwiftUI to recreate it whenever the parent view rebuilds, resetting its state.

_daily.dev surfaces SwiftUI patterns like this for developers debugging state resets in their views._

### Why does my SwiftUI view model reset its state every time the parent view updates?

This happens when an ObservableObject is created inline using @ObservedObject instead of @StateObject. Since @ObservedObject provides no persistent storage, SwiftUI can recreate the object each time it rebuilds the view's value, wiping out any accumulated state such as a counter. Switching the property wrapper to @StateObject fixes it by preserving the object across view identity.

_Developers chasing SwiftUI state bugs like this can find related fixes on daily.dev._

### Should I replace ObservableObject and @StateObject with @Observable in new SwiftUI code?

Yes, for code targeting iOS 17 and later, the Observation framework's @Observable macro combined with @State is recommended instead of ObservableObject, @Published, and @StateObject. An injected @Observable model typically needs no property wrapper, and @Bindable is only required when a child view needs bindings to the model's properties.

_daily.dev helps iOS developers weighing @Observable against ObservableObject stay on top of SwiftUI migration guidance._

---

Tags: [#ios](https://daily.dev/tags/ios), [#swift](https://daily.dev/tags/swift), [#swiftui](https://daily.dev/tags/swiftui)

[View this post on daily.dev](https://daily.dev/posts/stateobject-vs-observedobject-the-differences-explained-m59jsolm0)
