Enumerating The Reasons
summary
Argues that replacing tangled booleans with a single enum makes invalid states impossible and reduces bugs, demonstrates using Xcode regex to find many bools, constructs a four lifecycle states enum that replaces three separate BOOL flags, shows Swift features: associated values and protocol conformance, CaseIterable and RawRepresentable, moves UI logic into enum methods, and builds a working confetti feature for MyFitnessPal/MapMyRun as a real example to prove the approach scales and simplifies state-driven code.
AI-written summary · about
chapters (16)
- 0:00Start
- 1:42State Driven Development
- 2:01var instanceVariable : Bool
- 3:36Example
- 4:32func startworkout() return
- 7:26Perfect case for an enum
- 8:02Enums make invalid states impossible to represent!
- 9:19Extending enums with variables and functions
- 15:32Associated Values
- 18:51case workout InProgress(current: Workout) var navigationTitle : String
- 19:26Table View Cell Configurations
- 21:47View Controller Modes Viewing, Editing, New
- 23:16Workout Activity Types Running, Cycling, Swimming
- 25:40Confetti Moments Colors, Images
- 30:24Associated vs. Raw Values
- 33:23Enums and Optionals - Writing Self Documenting Swift Code Code Encapsulation in Swift Enumerations
related talks
26mState Driven Development - The Beauty of Enums in Swift
32mStupid Enum Tricks
24mLeveraging the Power of State Machines in Swift
21mOptimizing Swift code for separation of concerns and simplicity
14mSwift Techniques for Testing
39mSwift and You
27mICYMI: Enums Are...
19mThe Art of Functional State Management for iOS Apps
