SwiftUI is Apple's declarative framework for building user interfaces across iOS, iPadOS, macOS, watchOS, and tvOS, introduced in 2019. Unlike imperative UIKit, SwiftUI describes what the UI should look like at any given state, and the framework handles the rendering and updates automatically. It uses a reactive data flow model where UI components automatically update when underlying data changes, eliminating manual view controller management. The key mental model: views are cheap, ephemeral structs that SwiftUI recreates frequently—state lives elsewhere (in property wrappers like @State or @Observable models), and SwiftUI diffs the view tree to render only what changed. Master property wrappers and you've mastered 80% of SwiftUI.
What This Cheat Sheet Covers
This topic spans 25 focused tables and 166 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Property Wrappers
| Wrapper | Example | Description |
|---|---|---|
private var count = 0 | • View-owned mutable state for simple value types • SwiftUI automatically rerenders when the value changes. | |
var isOn: Bool | • Two-way connection to a parent's @State• changes propagate both up and down the view hierarchy. | |
var vm = ViewModel() | • View-owned reference type conforming to ObservableObject• survives view recreation and owns the object's lifetime. | |
var vm: ViewModel | • Externally-owned reference type • does not own the object—receives it from parent or environment. | |
var settings: Settings | • Dependency injection for shared objects passed down the view hierarchy • skips intermediate views. | |
@Observable class Model { var name = "" } | • Modern macro-based observation • no property wrappers needed in view—SwiftUI tracks only accessed properties. |