Posts

Showing posts from 2025

Swift & SwiftUI Interview Prep – Senior iOS Developers

Here are some of the key questions that came up: 1. What are PassThroughSubject and CurrentValueSubject? 2. Explain Publisher and Subscriber. 3. Difference between @State and @Binding in SwiftUI. 4. What is AnyPublisher? 5. When do we use eraseToAnyPublisher? 6. What is AnyView? 7. What does the @Published property wrapper do? 8. Write a Combine pipeline to fetch data from two different network requests and output only when both complete. (💻 Live Coding Test) 9. What is a Cancellable? 10.Types of operators in Combine. 11. Usage of sink with completion. 12. Explain switchToLatest. 13. Build a 2-screen SwiftUI app (list + detail) that makes an API call using Combine only. (⏱️ 20-min Live Coding Test) 14. Difference between onReceive and onChange modifiers. 15. Coding Exercise: 👉 Given an array of strings, transform it into a new array: Input → ["a", "b", "c"] Output → ["c-0", "b-1", "a-2"] ⚡️ Requirement: Solve this using Swif...

Need of Certificates & Provisioning Profiles in iOS Development

  Every iOS developer has this question at some point in their careers! “Why do we need to set up certificates, keys, and provisioning profiles just to run our own app?” It may look complicated — but it’s actually a well-thought-out security model. The logic behind it is simple - - Every iOS app runs in a sandboxed, secure environment. - Apple doesn’t allow unverified code to run on devices To make sure your app can be trusted before it runs, Apple verifies three things: 1.  Who you are → Developer Certificate 2.  Where your app can run → Provisioning Profile 3.  What your app can do → Entitlements Like working in a secure building: Your Developer Certificate is your Employee ID — it proves your identity and that you’re part of the company. Your Provisioning Profile is your Access Card — it determines which rooms (devices) you can enter. Your Entitlements are your Permissions — they define what you’re allowed to do once inside (like accessing confidential sy...

Stop using .onAppear() for async work in SwiftUI

.onAppear { Task { await viewModel.loadData() } } The problem? SwiftUI doesn't manage that Task for you. If the view disappears, your network call keeps running in the background. Even worse, onAppear can fire multiple times in certain navigation scenarios. 🐛 There's a better way: .task() .task { await viewModel.loadData() } That's it. SwiftUI automatically cancels the task when the view disappears. No memory leaks, no unnecessary work, no manual cleanup. But it gets even better with .task(id:) Let's say you're building a user profile screen. When the userID changes, you need to reload the data: .task(id: userID) { await viewModel.loadUser(userID) } Every time userID changes, SwiftUI cancels the previous task and starts a new one automatically. No need for .onChange(), no manual task cancellation logic. Quick comparison: ❌ .onAppear - Fires on appear, no automatic cancellation, can fire multiple times ✅ .task - Fires on appear, auto-cancels on disappear ✅ .tas...