This repository contains a small demo app that showcases SwiftUI state property wrappers in action.
It is designed as a companion project to the blog post “SwiftUI Bites #01 – State Management” and focuses on ownership, scope, and data flow, not on app architecture or frameworks.
👉 Blog post:
https://jochen-holzer.de/swiftui-bites-01-state-management-property-wrappers-when-to-use-what
The app demonstrates the five most important SwiftUI state property wrappers:
@State@Binding@StateObject@ObservedObject@EnvironmentObject
Each concept is shown in isolation and in combination, with inline comments explaining why a specific wrapper is used.
This is not a production app — it’s a learning playground.
The demo follows the same decision model described in the blog article.
flowchart TD
A["Is the state app-wide?"] -->|Yes| EO["@EnvironmentObject"]
A -->|No| B{"Value type or ObservableObject?"}
B -->|Value type| S["@State"]
B -->|ObservableObject| C{"Who creates the object?"}
C -->|This view| SO["@StateObject"]
C -->|Parent / external| OO["@ObservedObject"]
S --> D{"Does a child view need write access?"}
D -->|Yes| BI["@Binding (in child view)"]