TechDiary Tech Blog
Result Enum: Handling API Success and Failure Elegantly
Seren
|
24 Sep, 2026
Leave a comment
I became more careful with API completion handlers after debugging a catalog screen that could finish with both values set to nil. The request technically completed, but the caller could not tell whether the server had returned an empty response, decoding had failed, or someone had simply forgotten to pass an error. I replaced that […]
Swift Generics Advanced + Protocol Associated Types: From “Can Use” to “Can Design”
Seren
|
23 Sep, 2026
Leave a comment
I did not start using advanced Swift generics because I wanted a more abstract architecture. I used them because a synchronization feature allowed the wrong local cache and remote source to be connected. Both objects had methods named load and save, so the mistake looked reasonable until data reached the wrong layer. The fix was […]
Swift Higher-Order Functions: map, filter, reduce, flatMap in Real Projects
Seren
|
22 Sep, 2026
Leave a comment
I used to judge Swift collection code by line count. If a chain of map, filter, and reduce replaced a loop, I assumed the result was automatically better. A reporting feature changed that habit. The first functional version was short, but it performed unnecessary work and hid an important rule about refunded orders. The useful […]
Swift Closures Explained: @escaping, Non-Escaping, and Trailing Closures with Code
Seren
|
21 Sep, 2026
Leave a comment
I understood Swift closure syntax long before I understood closure lifetime. I could write map, completion handlers, and trailing closures without thinking about them. The gap only became obvious when a profile screen refused to deallocate after it was dismissed. The screen asked an avatar pipeline to load an image. The pipeline stored a completion […]
Deep Copy and Shallow Copy: The Complete Memory Change Principle
Seren
|
20 Sep, 2026
Leave a comment
I once treated “deep copy” and “shallow copy” as two simple vocabulary items: one duplicates everything, while the other only duplicates an address. That explanation was easy to remember, but it was not useful when a real bug appeared in an iOS project. The outer objects had different addresses, yet editing one screen still changed […]
Swift Value Type Copy-on-Write Mechanism
Seren
|
19 Sep, 2026
Leave a comment
I did not learn copy-on-write from an interview question. I learned it while profiling a document editor that kept a published version and an editable draft in memory at the same time. Each document contained thousands of text lines. I expected creating the draft to duplicate all of that storage immediately, but the assignment was […]
Objective-C Object Instance Memory Structure: An In-Depth Analysis
Seren
|
18 Sep, 2026
Leave a comment
The first time I tried to budget memory for a large Objective-C import, I made a neat spreadsheet and got the wrong answer. Each parsed record had an integer, a flag, and a title, so I counted those fields, multiplied by the number of records, and expected Instruments to agree. The process used considerably more […]
Root Class NSObject Internal Implementation Principle
Seren
|
17 Sep, 2026
Leave a comment
I once blamed NSObject for a memory problem that it did not cause. An import feature in one of my Objective-C tools created thousands of short-lived job objects. Instruments showed a larger memory increase than my rough calculation predicted, so I assumed that every object carried a mysterious fixed amount of hidden NSObject data. That […]
Instance Methods vs Class Methods: Where They’re Stored
Seren
|
16 Sep, 2026
Leave a comment
I finally learned where Objective-C methods are stored after I wrote the wrong capability check for a plugin system. The loader received a plugin class and needed to ask whether it supported an optional class-level feature. I searched the ordinary class object for that selector, got NULL, and disabled a feature the plugin actually implemented. […]
Application Scenarios of the Three Stages of Message Forwarding
Seren
|
15 Sep, 2026
Leave a comment
I used to think Objective-C message forwarding was mainly something to study for interviews. That changed during a checkout-module migration. We had an old analytics selector, a receipt exporter hidden behind a compatibility object, and two components that both needed an order-completion callback. All three problems involved a message the receiving object did not implement, […]
