The article explains why recursive enums need the indirect keyword. It covers the problem (value types need a known size at compile time, but recursive cases create infinite size), the solution (indirect stores the case via heap reference), case level versus enum level indirect, practical examples like expression trees and file systems, and trade offs including heap allocation and indirection cost.
The article compares three approaches to thread safety in Swift: actors (language level isolation with compiler enforcement), DispatchQueue (execution level coordination with serial or concurrent queues), and locks (critical section level control). It explains how each works under the hood, including actor reentrancy, queue deadlocks, lock recursion problems, and the new Mutex type from the Synchronization framework. It also covers atomics for simple operations and provides practical guidance on choosing based on safety, performance, API shape, and cognitive load.
The article explains immediate tasks (Task.immediate), a new feature in Swift 6.2 that starts executing synchronously on the caller's executor rather than being scheduled to run later. It covers when to use them (calling async code from synchronous actor code, preserving ordering), the risk of overhang (blocking the caller too long), immediate detached tasks, and immediate child tasks in task groups with addImmediateTask.
This is a transcript of a live Q&A session with Apple engineers answering specific questions about Swift Concurrency. Topics include the difference between Task { @MainActor in } and MainActor.run, the meaning of nonisolated and nonisolated(nonsending), using @concurrent for offloading work, task cancellation best practices, actor limits, the new withDeadline proposal, migration from Swift 5 to Swift 6 concurrency, and testing async code.
The article explains the evolution of onChange() from iOS 14 to iOS 17+. It covers the two new signatures, the initial parameter to trigger the action on first appear, the difference between View and Scene modifiers, and how to avoid blocking the main thread with async code.
The article explains how to create custom shapes by conforming to the Shape protocol. It starts with a basic triangle, then moves to an advanced star shape with configurable points and smoothness. It also covers animatable shapes using the Animatable protocol and common use cases like charts, logos, and progress indicators.
The article explains what makes Swift enums different from enums in other languages. It covers associated values (each case carries its own data), raw values (mapping to Int or String), computed properties and methods on enums, using enums with Error handling, recursive enums with indirect cases, and replacing class hierarchies with enums. It also includes a comparison with Kotlin sealed interfaces.
The article shows how Swift 6 concurrency features (default MainActor, isolated conformances, Sendable) affect protocol design. Using a simple DatabaseModel protocol, it explains why a conformance can fail due to isolation mismatch with Identifiable. It walks through solutions like changing default isolation, using nonisolated, requiring Sendable, or switching to async protocol requirements.
The article explains what inout parameters are, how copy-in copy-out works under the hood, and when to use them versus return values. It covers basic examples (incrementing, swapping, mutating collections), important rules (using &, variables only, no conflicting access), common mistakes, and best practices.
This newsletter issue covers iOS interview and coding topics. It includes how to answer the Single Responsibility Principle question strongly, designing an image caching system with memory, disk, and network layers, a SwiftUI tip about using @StateObject instead of @State for reference types, and a hot take on AI tools widening the gap between engineers who understand principles versus those who memorize patterns.