Lessons
async/await and Tasks
async functions, await, Task creation, async let for parallel execution, Task cancellation, and withTaskGroup.
What to look for:
- async: marks a function that can suspend — callers must await it
- async let: start two async operations concurrently before awaiting either
- Task { }: unstructured task — escapes the current async context; manages its own lifecycle
- Task cancellation propagates — check Task.isCancelled in long-running loops
Actors and @MainActor
actor type, actor isolation, await for actor access, @MainActor for UI code, Sendable protocol, and actor reentrancy.
Prerequisite: Lesson 1
What to look for:
- Accessing actor-isolated state requires await — compiler enforces this
- @MainActor: class/function runs on main thread — use for ViewModels and UI state
- Sendable: types safe to pass across actor boundaries — value types are Sendable by default
- Actor reentrancy: state can change at an await point — check invariants after each await
ARC: retain cycles and weak references
ARC vs GC, strong/weak/unowned, closure capture lists [weak self], delegate pattern, and deinit for verification.
Prerequisite: Lesson 2
What to look for:
- ARC inserts retain/release at compile time — deallocation is deterministic (unlike GC)
- Retain cycle: A strong-refs B; B strong-refs A — neither ever deallocates
- [weak self]: closure doesn't retain self — use guard let self = self inside the closure
- unowned: non-optional weak — crashes if accessed after deallocation; use carefully
Property wrappers: @State, @Binding, @Published
@propertyWrapper syntax, @State (local SwiftUI state), @Binding (two-way), @Published (ObservableObject), and @Environment.
Prerequisite: Lesson 3
What to look for:
- @State: view-local state — SwiftUI re-renders the view when it changes
- @Binding: two-way binding to state owned by a parent view — passes $state down
- @Published inside ObservableObject: publishes changes to all observers
- @StateObject vs @ObservedObject: StateObject creates AND owns; ObservedObject just observes
SwiftUI: declarative UI with the View protocol
View protocol, body computed property, HStack/VStack/ZStack, List, NavigationStack, modifiers chain, and previews.
Prerequisite: Lesson 4
What to look for:
- struct ContentView: View { var body: some View { ... } } — every SwiftUI view is a struct
- some View: opaque return type — the compiler knows the exact type; zero overhead
- Modifiers return new views: Text("Hello").font(.title).foregroundColor(.blue)
- SwiftUI diffs the view tree efficiently — only re-renders changed parts
After this track: You have a solid Swift foundation. Next steps: build a complete SwiftUI app (Apple's free tutorials at developer.apple.com/tutorials/swiftui are excellent), explore the Swift on Server ecosystem (Vapor), or dig into Swift Evolution proposals to understand where the language is heading.
Track quiz
4 questions to check your understanding.
How is ARC different from garbage collection?
Why should you use [weak self] in closures that reference self?
What does accessing an actor's property require in Swift?
What does some View mean as a return type in SwiftUI?