Skip to content

Wooder/SwiftUIBites-StateManagement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

SwiftUI Bites — State Management

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


🧠 What this project demonstrates

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.


🧭 SwiftUI State Decision Model

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)"]
Loading

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages