Category: Swift

Swift
Checked Continuations in Swift: Bridging Callback APIs Without Leaks or Double Resumes

By Seren  |  28 Aug, 2026
Leave a comment

My first continuation wrapper was only six lines long, and I was rather proud of it. A callback came in, I called resume, and an awkward legacy API suddenly worked with async/await. Then a cancellation test sat waiting until the test timeout. The callback API had a branch that returned without calling its completion handler. […]

Swift
Swift Sendable and @unchecked Sendable: A Practical Safety Checklist for Strict Concurrency

By Seren  |  27 Aug, 2026
Leave a comment

When I enabled stricter concurrency checking on an older Swift target, the warning list was long enough to be discouraging. Several types had crossed queues for years without an obvious crash, so adding @unchecked Sendable everywhere looked like the fastest way forward. I tried it on one wrapper and immediately disliked how quiet the compiler […]

Swift
Swift Actor Reentrancy Explained: Why Protected State Can Still Become Stale

By Seren  |  26 Aug, 2026
Leave a comment

The first time actor reentrancy really clicked for me, I was looking at two identical token-refresh requests in the network log. I had moved the token store into an actor, the compiler was happy, and I was convinced duplicate refreshes were no longer possible. Yet there they were, starting only milliseconds apart. My first reaction […]

Swift
Swift Task Cancellation in Practice: Stopping Stale Requests Before They Update the UI

By Seren  |  25 Aug, 2026
Leave a comment

I finally took task cancellation seriously after watching a search screen display the wrong result with perfectly valid network responses. I typed “sw,” paused briefly, and then completed the word “swift.” The second request finished first and the UI looked correct for a moment. Then the slower “sw” request returned and replaced the screen with […]

Swift
Swift Retain Cycles: Three Solutions and When to Use Each

By Seren  |  29 Jun, 2026
2 Comments

Retain cycles are the most common cause of memory leaks in Swift, and they are easy to create accidentally — a closure capturing self, a delegate held strongly, a notification center retaining an observer. I traced it back to a closure retain cycle—the view controller held a closure, and the closure captured self. Both objects […]

Swift
static vs class in Swift: When Type Methods Can (and Can’t) Be Overridden

By Seren  |  21 May, 2026
Leave a comment

I got a compiler error in the middle of a code review that I didn’t understand at first: “overriding declaration requires an ‘override’ keyword.” My subclass was trying to override a static method — but Swift wouldn’t let me. That’s when I realized static and class aren’t interchangeable; they have different meanings for inheritance and […]

Swift
Swift Struct mutating Keyword Explained: When Value Types Need to Modify Themselves

By Seren  |  18 May, 2026
Leave a comment

Swift mutating keyword exists because value types are immutable by default — a design choice that prevents accidental side effects but sometimes gets in the way when you need a struct method to modify its own properties. My first reaction was: it’s my own property, why can’t I change it? This problem sits right at […]

Swift
Swift Concurrency: Async/Await in Real Projects

By Seren  |  15 May, 2026
Leave a comment

Before 2021, writing asynchronous Swift code meant callback hell — nested closures, manual error propagation, and a lot of mental gymnastics. Swift 5.5 introduced async/await, and for the first time, async code could finally be written linearly, just like synchronous code. This article skips the theory. We’re starting with how to use it in real […]

Swift
Result Enum: Handling API Success and Failure Elegantly

By Seren  |  13 May, 2026
Leave a comment

A network request either succeeds or fails. But somehow, this simple binary outcome has led to some of the ugliest code I’ve seen — double closures, optional nils pretending to be errors, and callback pyramids full of if-else. Swift’s standard library Result enum was built exactly for this. This article doesn’t waste time on how […]

Swift
Swift Generics Advanced + Protocol Associated Types: From “Can Use” to “Can Design”

By Seren  |  11 May, 2026
Leave a comment

Everyone knows the basic generics syntax. But when it comes to associatedtype in protocols, generic constraints, and where clauses, many developers get stuck. This article skips the func swap<T>(_ a: inout T, _ b: inout T) beginner examples — I’m starting with when you actually need these advanced features in real projects. It took me […]