TechDiary Tech Blog
How I Fixed a Retain Cycle Between a Swift View Controller and an Async Callback
Seren
|
19 Oct, 2026
Leave a comment
I found this retain cycle after a screen that looked completely gone kept receiving updates from a slow network callback. The view controller disappeared, but its memory stayed around until the request finished. Instruments showed the leak; the difficult part was understanding why a small closure had kept an entire screen alive. The Screen That […]
Object Property Default Initialization Rules Explained
Seren
|
03 Oct, 2026
Leave a comment
I once shipped a download settings model with a retry limit that quietly started at zero. Nothing crashed, and the debugger showed a perfectly valid value. The problem was that zero was a memory default, while the product expected three retries. I had confused safe initialization with correct business configuration. Objective-C gives newly allocated object […]
Strong, Weak, Assign: The Essential Difference
Seren
|
02 Oct, 2026
Leave a comment
The difference between strong, weak, and assign became real to me while debugging a download screen that would not disappear. The coordinator kept working correctly, but the screen stayed in memory after navigation. The cause was not ARC itself. I had accidentally made the coordinator own its delegate. Changing the delegate to weak fixed the […]
Runtime Dynamic Method Addition and Method Swizzling in Practice: From Principles to Black Magic
Seren
|
01 Oct, 2026
Leave a comment
I first used method swizzling in a checkout feature that needed temporary timing logs around an existing service method. The tempting solution was to exchange implementations at application launch and forget about it. That worked in a test build, but it also made every call site depend on a global behavior change that was difficult […]
ARC Automatic Memory Management: Core Decision Logic
Seren
|
30 Sep, 2026
Leave a comment
ARC became easier for me to reason about when I stopped trying to predict an invisible reference count after every line. In one resource-loading feature, a downloaded image stayed alive after the request finished. The request was not the owner anymore, but a dictionary cache still was. The fix came from finding that ownership path, […]
Swift Retain Cycles: Three Solutions and When to Use Each
Seren
|
29 Sep, 2026
2 Comments
I stopped adding [weak self] to every Swift closure after debugging a download screen that stayed alive after it was closed. The leak was real, but the useful lesson was not that closures are dangerous. The problem was a specific ownership loop: the screen model owned a progress source, the source stored a closure, and […]
Block Underlying Structure and Variable Capture Explained
Seren
|
28 Sep, 2026
1 Comment
I understood Objective-C Blocks much better after I stopped treating variable capture as a list of interview rules. The problem became concrete while I was building a small batch uploader. Each queued operation needed to remember its file name, all operations needed to update one retry budget, and the coordinator needed a progress callback without […]
static vs class in Swift: When Type Methods Can (and Can’t) Be Overridden
Seren
|
27 Sep, 2026
Leave a comment
I used to choose between Swift’s static and class keywords by habit. If a function belonged to a type instead of an instance, I usually wrote static and moved on. That worked until I built a notification layer where each delivery channel needed its own type-level behavior. Email and SMS builders shared validation and construction […]
Swift Struct mutating Keyword Explained: When Value Types Need to Modify Themselves
Seren
|
26 Sep, 2026
Leave a comment
I stopped thinking of Swift’s mutating keyword as a compiler formality after building a checkout model with several valid stages. A cart could be edited while shopping, locked before payment, marked as paid, or reset. Letting outside code assign those properties directly made invalid combinations too easy to create. I moved the transitions into a […]
Swift Concurrency: Async/Await in Real Projects
Seren
|
25 Sep, 2026
Leave a comment
My first useful Swift concurrency refactor was not a large rewrite. It was a dashboard screen that loaded a profile, notifications, and small labels for each notification. The callback version worked, but it mixed request coordination, error handling, shared cache updates, and UI delivery in one difficult-to-review function. I rebuilt that flow as a small […]
