Flexible View Controller Interfaces With Swift 4
summary
Demonstrates using Swift 4 existentials to replace repeated storyboard casting by defining a small protocol for the interface, combining it with UIViewController via protocol composition, and exposing a single reusable type with a typealias combining protocol and UIViewController. Uses a demo app that flips a UserDefaults feature flag to swap two storyboard controllers (identifiers "legacy" and a new UI). Result: one safe cast, no duplicated setup code, and seamless runtime swapping.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:25Overview
- 2:14Perspective
- 4:16Miss headers
- 5:16Swift as a language
- 7:49Pros Cons
- 8:52Feature Flags
- 10:10Demo
- 12:59Lying to the compiler
- 14:10Adding a protocol
- 18:21Aliasing the protocol
related talks
43mRefactoring a Massive View Controller in Swift
17mMVC: Many View Controllers
41mWhen You Can’t Go All In On SwiftUI, Build a Hybrid UI App Instead!
18mBuckets of Code
44mSeparation of concerns: Refactoring view controllers live
29mTable View Controllers in Swift
19mFinally Solving the Expression Problem
16mSwiftUI API Design Lessons:Bridging Procedural APIs with theDeclarativeWorld
