---
title: "Discussion on \"MVVM in SwiftUI\" | Hashnode"
description: "Discussion on \"MVVM in SwiftUI\". A tutorial on making a Post view with Model-View-ViewModel Design Pattern"
url: "https://hashnode.com/posts/mvvm-in-swiftui/6451db571f2e7841f809e850"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [MVVM in SwiftUI](https://xavier7t.com/mvvm-in-swiftui?utm_source=hashnode&utm_medium=feed)

A tutorial on making a Post view with Model-View-ViewModel Design Pattern

May 3, 2023 · 4 min read · xavier7t.com  
Read the article

-   [#ios](https://hashnode.com/tag/ios)
-   [#swift](https://hashnode.com/tag/swift)
-   [#swiftui](https://hashnode.com/tag/swiftui)
-   [#iosdevx](https://hashnode.com/tag/iosdevx)
-   [#mvvm](https://hashnode.com/tag/mvvm)

## Written by

[Xavier](https://hashnode.com/@xavier7t)

@xavier7t · Toronto, ON, CAN

  
[View profile](https://hashnode.com/@xavier7t)

iOS Developer

iOS developer from Toronto, ON, CAN

## Responses 1

Markdown supported · ⌘↵ to post

[Abdurahmon Jamoliddinov](https://hashnode.com/@abdudev)

[Jan 9, 2024](https://hashnode.com/posts/mvvm-in-swiftui/6451db571f2e7841f809e850/comment/659cdee0b80581bc195dcf7b)

What do you think about using @ObservedObject instead of @StateObject, is it good practice or is it better to use @StateObject?

[Xavier](https://hashnode.com/@xavier7t)

[Sep 15, 2024](https://hashnode.com/posts/mvvm-in-swiftui/6451db571f2e7841f809e850/comment/659cdee0b80581bc195dcf7b#reply-66e64dff28240e8a143354a9)

it depends on the case. State is the source of truth. So use `StateObject` in views where the data is created/captured. Other views should use `ObservedObject` to observe the state.
