Master Swift Optionals, Structs and Actors: 48 Flashcards for iOS Developers
Learn Swift with 48 flashcards: optionals and guard let, struct vs class, protocol extensions, weak vs unowned, async/await and actors, plus 4 cards to fix.

Studying. But it's also a video game. 🎮
Flashcards, quizzes and games that make you actually remember.
Posted by
Related reading
Kotlin Essentials Flashcards: Null Safety, Scope Functions and the Cards to Add
Study Kotlin with 42 flashcards: val vs var, final-by-default classes, Elvis and safe-call operators, scope functions, plus the coroutine cards the deck misses.
Memorize Rust Ownership and Borrowing: 48 Flashcards from the Three Rules to Arc and Mutex
Learn Rust with 48 real flashcards: ownership rules, borrowing, String vs str, Option, Result, the question-mark operator, Box, Rc, Arc, traits and unsafe.
Go Essentials Study Guide: 49 Flashcards on Goroutines, Slices, Interfaces and Defer
Learn Go (Golang) with 49 flashcards: syntax, slices vs arrays, make vs new, interfaces, defer, goroutines, channels and the scheduler, plus a one-week drill plan.
Swift enforces what Objective-C left to convention: nothing is nil unless you say so, structs are copied, and a switch over an enum must cover every case. Deck UL5709 — Swift Essentials turns that contract into 48 flashcards, almost all carrying compilable code on the back. Here is the map, plus the four cards to repair before your first review.
Study this deck: Swift Essentials
1 / 10Swift
Tap the card for the answer · swipe right if you knew it, left if not
The 48 cards, block by block
- Optionals — the spine of the deck (7 cards):
String?declarations, optional binding withif let,guard let, optional chaining (person?.address?.city), nil coalescing??, forced unwrapping!, implicitly unwrapped optionals for IBOutlets - Types and semantics:
Int8/Int16/Int32/Int64/UInt,Float,Double,Bool,String,Character,Array<T>,Dictionary<K,V>,Set<T>, struct vs class, value copies vs shared references,mutating,is/as?/as!,AnyvsAnyObject - Properties and init: computed properties (
get/set),willSet/didSetobservers,lazy var,staticvsclassmembers, custominit, failableinit?,override/super,final - Protocols, enums, generics: protocol requirements, protocol extensions as default implementations, enums with associated values, exhaustive
switch,if case .success(let msg), genericStack<Element>, type constraints (<T: Equatable>),extension Int - Memory and concurrency: retain cycles,
weakvsunowned, capture lists[weak self],@escaping,defer,do/try/catch,try?andtry!,map/filter/reduce/compactMap/flatMap,async/await,Task,actor
Ten cards to quiz yourself on right now
| Front | Back (condensed) |
|---|---|
| Nil coalescing operator | let name = optionalName ?? "default" — supplies a fallback when the optional is nil |
| Optional chaining | person?.address?.city — calls through only if non-nil, returns an optional, stops at the first nil |
| struct vs class | Struct: value type, copied, no inheritance, no deinit. Class: reference type, shared, inheritance, deinit |
| Guard statement | guard let name = optionalName else { return } — early exit, unwrapped value stays in scope afterwards |
| Protocol extension | extension Drawable { func describe() { … } } — default implementation every conforming type inherits |
| Weak vs unowned | weak: optional, becomes nil on deallocation. unowned: non-optional, assumes the object outlives you |
| Capture list | someMethod { [weak self] in self?.doSomething() } — breaks the closure's retain cycle |
| CompactMap | ["1","2","three","4"].compactMap { Int($0) } → [1, 2, 4] — maps and drops nils |
| Failable initializer | init?(name: String) { if name.isEmpty { return nil } … } — returns an optional instance |
| Actor | actor BankAccount { … } — reference type with serialized access; call it with await |
Four cards to fix before you start
- Card 19 redefines
Result. It declares its ownenum Result { case success(String); case failure(Error) }, but Swift has shippedResult<Success, Failure>since 5.0 — rename the deck's toMyResult. - Three backs are truncated mid-word: error handling stops at
print("Other error: \(er, the escaping-closure card atNeed [weak self] to avo, the struct-methods card atcoun. Finish them from memory, it is a free extra rep. - Hello World contradicts itself: it says "no main function needed", then shows one. For an app target the modern answer is
@mainon a type withstatic func main(). flatMapneeds a footnote: flattening nested arrays is right, butflatMapover a sequence of optionals was deprecated in Swift 4.1 in favour ofcompactMap.
Two drills that fit this deck
The unwrap ladder. Take one optional and write all five handling paths in a row: if let, guard let, ??, ?., !. The deck teaches them as five separate cards; interviews ask which one you'd pick and why.
The struct/class flip. Card 16 gives the three reasons to reach for a class — inheritance, reference semantics, a deinitializer. Go through the type cards and name which of the three applies. Everything else stays a struct.
Deck UL5709 — Swift Essentials is in the Flip It library at flip-it.app. Coming from another modern language? Compare notes with the Go Essentials study guide or the Rust ownership and borrowing deck.
Ready to learn faster? 🚀
Join FLIP IT for free and turn studying into a game.