If you captured any state before doing some async work in your actor, then by the time your task is resumed, your captured state may be stale. This is what actor reentrancy is about. Because of this, you should avoid capturing things that are subject to change before your task is suspended. Instead, only retrieve values after your task is resumed. Code Let’s just dive into code samples: Example 1 - No Async work import Foundation protocol Incrementer { // increments the value of a dictionary....
Systems Design - Pagination
Cursor-Based Pagination: Handling Deletions, Collisions & Secure Cursors Pagination requires subtle implementation for a smooth infinite scroll. In this post I’ll share what I learned while reading on cursor‑based pagination for a real‑time feed – how it differs from the classic offset/limit approach, how it deals with deletions and timestamp collisions, what goes into a cursor (spoiler: it’s not a random token), why you should (or shouldn’t) protect cursors from tampering, what to cache and how to manage stale data....
High Level Anatomy of a Camera Capturing Session
I used the following tutorial series from Apple on ‘Capturing and Displaying Photos’. They’re great. Just that it took me a bit to be able to piece together how components from AVFoundation work together. Working with AVFoundation isn’t really the kind where you read documentation and then can piece things together. It’s complicated. You might understand an individual step, but won’t understand when it should be done. There’s just too many components and while it’s not low-level, it’s certainly a different kind of iOS....
What Is a Suspension Point In Swift?
A suspension point doesn’t mean the current thread is blocked. Nor it means the current actor is blocked. All it means is that the current task / function is blocked / suspended / waiting for an asynchronous task to finish. @MainActor func foo() async { doA() let b = await doB() doC() } When you get to doB(), then the MainActor / Main Thread are not suspended. Other tasks can be enqueued and executed on the main thread....
Live Activities Part 1 - Problem Statement
I recently went on a quest for Live Activities. There’s a ton of gotchas or subtle notes that aren’t clearly mentioned. Think of the series as an unofficial rfc. Intro Example app - wwdc code - docs confusion points I saw Apple’s videos and docs on ActivityKit. They do a decent job of showing you 80% of the API and how Live Activity works. The remaining 20% is an enigma though....
Live Activities Part 2 - The missing doc
How do I begin development for Live Activities? Add a new† (widget) target to your app. Make sure you select ‘Live Activities’. Add the necessary plist items. Add push notification capability. Only needed if you want to start / update from server. If everything is done from within the app then you don’t need this. Example ‘Clock’ App on iPhone adds timers to your phone without any server interaction. Note: A widget is a specific kind of app extension....
Live Activities Part 3 - Development
Development How can I share classes between widget and app? Models must be shared across targets. App needs the model to manage its lifecycle (start, update, end, handling dismissed / stale activities). Widget needs the model to be able to present it. Each View should only get added to targets that needs them. Your widget must create views based on the models for all Live Activity presentations. Your app may need views if it has an in-app view related to the live activity....
Live Activities Part 4 - Debugging
Debugging Notification delivery issues Can you send Live Activity notifications to simulator? Yes. The token created by the simulator works. Just don’t use the simulator for testing application lifecycle behavior or background tasks as a may not properly simulate OS restrictions. Can you drag and drop payloads into the simulator? That didn’t work for me. Timing of ‘Token Registration’ vs ‘Payload Sending’ Make sure the tokens are stored in your servers before sending the payload....
Swift Actors: few random notes
This post isn’t meant to explain how actors work. Rather just elaborate a few tiny details. I’m often curious about the origins of things. How people met, dated or how they began their careers or founded their companies. Similarly about namings, understanding the context often gives you a foundational understanding. I give feedback in Pull Requests about variable and type names or seek advice through code-review channels. First time it occurred was when someone explained that the reduce function means “how you jam and reduce an entire array into a single value”....
Interviewing - Final Round Learnings
After going through a final-round interviews as a senior iOS engineer, I’ve learned that technical skills alone aren’t enough. The best candidates excel across multiple dimensions: system design thinking, behavioral storytelling, code review acumen, and interview presence. This post captures the hard-won lessons from my recent interview experiences—what worked, what didn’t, and what I’d do differently next time. These aren’t theoretical tips, but practical insights that came from real feedback and reflection....