Senior iOS Developer Interview Questions and Answers

Milad Bonakdar
Author
Prepare for senior iOS interviews with practical questions on Swift, SwiftUI, architecture, concurrency, performance, Core Data, offline sync, and security.
Introduction
Senior iOS interviews test whether you can connect Swift and Apple framework details to production decisions: architecture, state management, concurrency, performance, data persistence, security, and trade-offs in a real app.
Use this guide to practice answers that start with the decision, explain the failure mode, and name the tool you would use in Xcode or the codebase. A senior answer should be practical enough for a team to trust in code review, not just a definition memorized from documentation.
Advanced Swift & Language Features (6 Questions)
1. Explain Swift's memory management and ARC (Automatic Reference Counting).
Answer: ARC automatically manages memory by tracking and managing references to class instances.
- How it works: Each class instance has a reference count. When count reaches zero, the instance is deallocated.
- Strong References: Default. Increases reference count.
- Weak References: Don't increase reference count. Automatically become
nilwhen the instance is deallocated. - Unowned References: Don't increase reference count but assume the instance always exists.
- Retain Cycles: Occur when two objects hold strong references to each other, preventing deallocation.
Rarity: Very Common Difficulty: Hard
2. What are Generics in Swift and why are they useful?
Answer: Generics allow you to write flexible, reusable functions and types that can work with any type.
- Benefits: Code reusability, type safety, performance (no runtime overhead)
- Type Constraints: Restrict generic types to specific protocols or classes
- Associated Types: Used in protocols to define placeholder types
Rarity: Common Difficulty: Medium
3. Explain the difference between escaping and non-escaping closures.
Answer:
- Non-escaping (default): The closure is executed before the function returns. Compiler can optimize better.
- Escaping (
@escaping): The closure outlives the function (stored in a property, called asynchronously). Must explicitly captureself.
Rarity: Common Difficulty: Medium
4. What is the difference between map, flatMap, and compactMap?
Answer: These are higher-order functions for transforming collections:
map: Transforms each element and returns an array of resultscompactMap: Likemapbut filters outnilvaluesflatMap: Flattens nested arrays into a single array
Rarity: Common Difficulty: Easy
5. Explain Property Wrappers in Swift.
Answer: Property wrappers separate the storage behavior of a property from the code that uses it. In iOS interviews, connect this to SwiftUI data flow rather than only showing a custom wrapper.
- SwiftUI state:
@Stateowns simple view-local state,@Bindingpasses writable state to a child view, and@AppStoragebridges small values to UserDefaults. - Reference models: Existing
ObservableObjectcode commonly uses@StateObjectfor ownership and@ObservedObjectfor injection from a parent. - Modern SwiftUI: With the Observation framework, an
@Observablemodel can reduce wrapper noise, but you should still be clear about ownership and mutation boundaries. - Custom wrappers: Useful for repeated storage, validation, or formatting behavior when the abstraction stays easy to test.
Rarity: Medium Difficulty: Hard
6. What is the Result type and how is it used?
Answer:
Result is an enum that represents either success or failure, making error handling more explicit.
- Definition:
enum Result<Success, Failure: Error> - Benefits: Type-safe error handling, clearer API contracts, better than throwing functions for async code
Rarity: Common Difficulty: Medium
Architecture Patterns (5 Questions)
7. Explain the MVVM (Model-View-ViewModel) pattern.
Answer: MVVM separates rendering from presentation state and business coordination. A senior answer should also explain where MVVM stops: navigation, data access, analytics, and side effects usually belong in coordinators, repositories, services, or dedicated use-case objects.
- Model: Domain data and business rules
- View: UIKit view controller or SwiftUI view that renders state and forwards user intent
- ViewModel: Presentation state, validation, loading/error state, and calls into injected dependencies
- Benefits: Easier unit testing, thinner views, clearer ownership of UI state
- Watch out: Do not let the ViewModel become a service locator or a dumping ground for networking, persistence, and navigation.
Rarity: Very Common Difficulty: Medium
8. What is the Coordinator pattern and why use it?
Answer: The Coordinator pattern separates navigation logic from view controllers.
- Problem: Massive View Controllers with navigation logic mixed with UI logic
- Solution: Coordinators handle navigation flow
- Benefits: Reusable view controllers, testable navigation, clear app flow
Rarity: Medium Difficulty: Hard
9. Explain Dependency Injection in iOS.
Answer: Dependency Injection is a design pattern where dependencies are provided to an object rather than created internally.
- Benefits: Testability (inject mocks), flexibility, loose coupling
- Types:
- Constructor Injection: Pass dependencies via initializer (most common)
- Property Injection: Set dependencies after initialization
- Method Injection: Pass dependencies as method parameters
Rarity: Common Difficulty: Medium
10. What is the Repository pattern?
Answer: The Repository pattern abstracts data access logic, providing a clean API for data operations.
- Benefits: Centralized data logic, easy to switch data sources (API, database, cache), testable
- Implementation: Repository coordinates between multiple data sources
Rarity: Medium Difficulty: Medium
11. Explain the differences between MVC, MVP, and MVVM.
Answer:
- MVC (Model-View-Controller):
- Apple's default pattern
- Controller mediates between Model and View
- Problem: Massive View Controllers
- MVP (Model-View-Presenter):
- Presenter handles all UI logic
- View is passive (just displays data)
- Better testability than MVC
- MVVM (Model-View-ViewModel):
- ViewModel exposes data streams
- View binds to ViewModel
- Best for reactive programming (Combine, RxSwift)
Rarity: Common Difficulty: Hard
Performance & Optimization (5 Questions)
12. How do you optimize table view and collection view performance?
Answer: Start by measuring. For table and collection views, the goal is to keep cell configuration cheap, avoid main-thread stalls, and prevent image work from racing reused cells.
- Cell Reuse: Use
dequeueReusableCellproperly - Avoid Heavy Operations: Don't perform expensive calculations in
cellForRowAt - Image Optimization:
- Resize images to display size
- Use background threads for image processing
- Cache decoded images
- Prefetching: Implement
UITableViewDataSourcePrefetching - Height Caching: Cache calculated cell heights
- Cancellation: Cancel in-flight image or network work when a cell is reused
- Measure: Use Instruments and Xcode debugging tools before claiming a fix worked
Rarity: Very Common Difficulty: Medium
13. Explain instruments and how you use them for performance profiling.
Answer: Instruments is Xcode's performance analysis tool.
- Common Instruments:
- Time Profiler: Identifies CPU-intensive code
- Allocations: Tracks memory allocations and leaks
- Leaks: Detects memory leaks
- Network: Monitors network activity
- Energy Log: Analyzes battery usage
- Workflow:
- Profile app (Cmd+I)
- Choose instrument
- Record and interact with app
- Analyze call tree and timeline
- Identify bottlenecks
Rarity: Common Difficulty: Medium
14. How do you detect and fix memory leaks?
Answer: Memory leaks occur when objects aren't deallocated when no longer needed.
- Common Causes:
- Retain cycles (strong reference cycles)
- Closures capturing
selfstrongly - Delegates not marked as
weak
- Detection:
- Instruments Leaks tool
- Memory Graph Debugger in Xcode
- Watch for increasing memory usage
- Fixes:
- Use
weakorunownedfor delegates - Use
[weak self]or[unowned self]in closures - Break retain cycles
- Use
Rarity: Very Common Difficulty: Medium
15. What techniques do you use for app startup optimization?
Answer: Faster app launch improves user experience:
- Lazy Loading: Initialize objects only when needed
- Reduce Dylib Loading: Minimize dynamic libraries
- Optimize
application:didFinishLaunching:- Move non-critical work to background
- Defer heavy initialization
- Binary Size: Smaller binary loads faster
- Avoid Heavy Operations: Don't block main thread
- Measure: Use Instruments' App Launch template
Rarity: Common Difficulty: Medium
16. How do you handle image caching and loading?
Answer: Efficient image handling is crucial for performance:
- Strategies:
- Memory Cache: Fast access, limited size
- Disk Cache: Persistent, larger capacity
- Download: Fetch from network
- Libraries: SDWebImage, Kingfisher (handle caching automatically)
- Custom Implementation:
Rarity: Common Difficulty: Hard
Concurrency & Async Programming (4 Questions)
17. Explain async/await in Swift.
Answer: Swift's modern concurrency model, introduced in Swift 5.5 and expanded since, gives you structured asynchronous code instead of deeply nested completion handlers.
- Benefits: Cleaner syntax, natural
try/catch, structured task lifetimes, cancellation propagation, and stronger compiler help around isolation - Keywords:
async: Marks a function that can suspendawait: Marks a suspension pointTask: Creates a new asynchronous contextactor: Thread-safe reference type@MainActor: Isolates UI-facing work to the main actor
For networking, prefer APIs such as URLSession.shared.data(from:) or data(for:) when they fit. For UI updates, return to the main actor instead of manually hopping through GCD.
Rarity: Very Common Difficulty: Hard
18. What are Actors in Swift?
Answer: Actors are reference types that protect their mutable state from data races.
- Thread Safety: Only one task can access actor's mutable state at a time
- Automatic Synchronization: Compiler enforces safe access
- Main Actor: Special actor for UI updates
- Senior caveat: Actors do not remove the need to think about reentrancy, cancellation, or how much work you isolate behind one actor.
Rarity: Medium Difficulty: Hard
19. Explain the Combine framework.
Answer: Combine is Apple's reactive programming framework. It still appears in many production iOS codebases, especially around search, form input, notifications, and legacy reactive flows, even when newer code uses async/await.
- Core Concepts:
- Publisher: Emits values over time
- Subscriber: Receives values
- Operator: Transforms values
- Benefits: Declarative, composable, built-in operators
- Use Cases: User input handling, data binding, notifications, timers, and bridging older pipelines during Swift concurrency migrations
- Trade-off: Combine can make streams concise, but overusing operators can hide control flow. In interviews, explain when async/await is simpler.
Rarity: Common Difficulty: Hard
20. What is the difference between Serial and Concurrent queues?
Answer: Dispatch queues execute tasks either serially or concurrently:
- Serial Queue: Executes one task at a time in FIFO order. Tasks wait for previous task to complete.
- Concurrent Queue: Executes multiple tasks simultaneously. Tasks start in FIFO order but can finish in any order.
- Main Queue: Special serial queue for UI updates
Rarity: Common Difficulty: Medium
Core Data & Persistence (3 Questions)
21. Explain Core Data architecture and its main components.
Answer: Core Data is Apple's object graph and persistence framework.
- NSManagedObjectModel: Schema definition (entities, attributes, relationships)
- NSPersistentStoreCoordinator: Coordinates between context and store
- NSManagedObjectContext: Working memory for objects (like a scratch pad)
- NSPersistentStore: Actual storage (SQLite, binary, in-memory)
Rarity: Common Difficulty: Medium
22. How do you handle concurrency in Core Data?
Answer: Core Data contexts are not thread-safe. Use proper concurrency patterns:
- Context Types:
- Main Queue Context: For UI operations
- Private Queue Context: For background operations
- Best Practices:
- Never pass managed objects between threads
- Use
performorperformAndWaitfor context operations - Pass object IDs between contexts
Rarity: Medium Difficulty: Hard
23. What is NSFetchedResultsController and when do you use it?
Answer:
NSFetchedResultsController efficiently manages Core Data results for table/collection views.
- Benefits:
- Automatic change tracking
- Memory efficient (batching)
- Section management
- Automatic UI updates
- Use Case: Displaying Core Data objects in table/collection views
Rarity: Medium Difficulty: Medium
System Design & Best Practices (2 Questions)
24. How would you design an offline-first mobile app?
Answer: Offline-first apps keep core workflows usable without a network and sync safely when connectivity returns. For a senior answer, define the source of truth, conflict strategy, and user-facing failure states.
- Architecture:
- Local database as source of truth (Core Data, Realm)
- Sync layer to reconcile with server
- Conflict resolution strategy
- Strategies:
- Optimistic UI: Show changes immediately, sync in background
- Queue Operations: Store failed requests, retry when online
- Timestamp/Version: Track data freshness
- Idempotent Sync: Use stable IDs and retry-safe operations where possible
- Challenges:
- Conflict resolution (last-write-wins, merge, user choice)
- Data consistency
- Storage limits
- Clear UI for pending, synced, and failed states
Rarity: Medium Difficulty: Hard
25. What are your strategies for app security in iOS?
Answer: Multiple layers protect app and user data:
- Data Protection:
- Keychain for sensitive data (passwords, tokens)
- Encrypt data at rest
- Use Data Protection API
- Network Security:
- HTTPS only (App Transport Security)
- Consider certificate pinning only for high-risk APIs, with a rotation and failure plan
- Validate server trust and avoid disabling TLS checks in debug code that can leak to production
- Code Security:
- No hardcoded secrets
- Treat obfuscation and jailbreak detection as defense-in-depth, not primary controls
- Authentication:
- Biometric authentication (Face ID, Touch ID)
- Secure token storage
- Token refresh mechanism
- Input Validation:
- Sanitize user input
- Prevent injection attacks
- Privacy:
- Minimize stored personal data
- Avoid logging tokens, credentials, or sensitive profile information
Rarity: Common Difficulty: Hard


