<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/stateobject-vs-observedobject-the-differences-explained-m59jsolm0" -->

---
title: @StateObject vs. @ObservedObject: The differences explained
description: Explains the difference between SwiftUI's @StateObject and @ObservedObject property wrappers: use @StateObject when a view creates and owns an...
canonical: https://daily.dev/posts/stateobject-vs-observedobject-the-differences-explained-m59jsolm0
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: @StateObject vs. @ObservedObject: The differences explained | daily.dev
og:description: Explains the difference between SwiftUI's @StateObject and @ObservedObject property wrappers: use @StateObject when a view creates and owns an...
og:url: https://daily.dev/posts/stateobject-vs-observedobject-the-differences-explained-m59jsolm0
og:image: https://api.daily.dev/og/posts/m59jsolM0.png
og:image:alt: @StateObject vs. @ObservedObject: The differences explained
og:image:width: 1200
og:image:height: 630
og:locale: 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._

## Similar posts on daily.dev

- [SwiftUI data dependencies and their effect on view updates](https://daily.dev/posts/swiftui-data-dependencies-and-their-effect-on-view-updates-2kp42i6if) · Nil Coalescing · 1 upvotes · 0 comments
- [Who Told The View To Update?](https://daily.dev/posts/who-told-the-view-to-update--xvxtydysb) · Medium · 0 upvotes · 0 comments

---

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)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"@StateObject vs. @ObservedObject: The differences explained","url":"https://daily.dev/posts/stateobject-vs-observedobject-the-differences-explained-m59jsolm0","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/stateobject-vs-observedobject-the-differences-explained-m59jsolm0"},"datePublished":"2026-08-24T14:05:40.130Z","dateModified":"2026-08-24T14:06:02.620Z","description":"Explains the difference between SwiftUI's @StateObject and @ObservedObject property wrappers: use @StateObject when a view creates and owns an...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed87c792f4619ebabb3333f2ba5edeb?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed87c792f4619ebabb3333f2ba5edeb?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"SwiftLee","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"SwiftLee","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/407bdbf78c69402985a468cb336a76ae","url":"https://daily.dev/sources/avanderlee"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/stateobject-vs-observedobject-the-differences-explained-m59jsolm0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ios,swift,swiftui","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"SwiftLee","item":"https://daily.dev/sources/avanderlee"},{"@type":"ListItem","position":3,"name":"@StateObject vs. @ObservedObject: The differences explained"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/stateobject-vs-observedobject-the-differences-explained-m59jsolm0#faq","mainEntity":[{"@type":"Question","name":"When should I use @StateObject versus @ObservedObject in SwiftUI?","acceptedAnswer":{"@type":"Answer","text":"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."}},{"@type":"Question","name":"Why does my SwiftUI view model reset its state every time the parent view updates?","acceptedAnswer":{"@type":"Answer","text":"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."}},{"@type":"Question","name":"Should I replace ObservableObject and @StateObject with @Observable in new SwiftUI code?","acceptedAnswer":{"@type":"Answer","text":"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."}}]}
```

