February 6, 2024
I've just released the beta of my new book The Mystery of the Mutating Mannequin.
This book explores dataflow in SwiftUI apps and the beta includes the first three chapters.
Chapter 1 looks at simple views with no state. We focus on how the view is assembled and, in particular, what modifiers add to the view hierarchy.
Chapter 2 introduces state and we look at simple properties and @State and look at when views redraw and why. It's material that we know about SwiftUI but here we have the ability to poke and prod a bit and get to understand the mechanism a little better.
Chapter 3 is an exploration of shared state. We begin with two views that use @Binding to share state and then move to a more robust model that uses @ObservableObject and @Published. We replace this solution that uses Combine with AsyncStreams and then look at @Observable objects (which are not the same as @ObservableObjects) and @Bindable.
Up next Chapter 4 manages an object graph manually and with Core Data with a tiny preview of SwiftData. Chapter 5 is an introduction to SwiftData.
Do you know all this stuff? Probably. But I have to say I'm a little embarrassed to admit that I didn't know some of the stuff I was sure I knew.