ios_interview_2025_03_23_183554 Flashcards
(31 cards)
- What are the main differences between Structs and Classes in Swift? When would you use one over the other?
Structs are value types, meaning they are copied when assigned or passed to a function, while Classes are reference types, meaning they share the same instance across different references. Use structs when immutability and thread safety are important (e.g., model data) and classes when you need shared state or object identity (e.g., ViewModels, service layers).
- Explain ARC (Automatic Reference Counting) in Swift. How do retain cycles happen, and how can you avoid them?
ARC automatically manages memory by increasing and decreasing reference counts for objects stored in the Heap.
Stack stores local variables and structs, releasing memory automatically when the scope ends.
Heap stores class instances, requiring ARC to control their lifecycle.
Retain cycles occur when two objects in the Heap hold strong references to each other, preventing deallocation. To avoid this, use weak or unowned references in closures or the delegate pattern.
What are property wrappers in Swift? Can you give some examples?
Property wrappers add custom logic around property storage. Examples:
@State (SwiftUI state management)
@Published (observable properties in Combine)
@AppStorage (UserDefaults storage)Use them to simplify property behaviors and encapsulate logic.
How do you handle state management in SwiftUI?
SwiftUI provides different tools for state management:
@State for local state within a view
@StateObject for reference-type objects owned by a view
@ObservedObject for external observed objects
@EnvironmentObject for global dependencies
What is the difference between async/await and GCD (Grand Central Dispatch)?
When would you choose one over the other?
Async/await provides structured concurrency, making asynchronous code easier to read
and maintain. GCD provides fine-grained control over queues and threading. Use
async/await for clean, sequential async tasks and GCD when managing complex
concurrency (e.g., low-level threading optimizations).
Can you explain the main differences between SwiftUI and UIKit in terms of
rendering, performance, and lifecycle?
SwiftUI is declarative, using a diffing system for rendering, whereas UIKit follows an
imperative approach with a view hierarchy. SwiftUI is generally more efficient for UI updates
but has fewer customization options than UIKit. UIKit provides more control over lifecycle
and event handling.
How would you design a networking layer in an iOS app? What are best practices
for handling API requests?
A well-structured networking layer should include an APIClient using URLSession (or
Alamofire), models for request/response parsing, and error handling. Use dependency
injection for testability and adopt Combine or async/await for handling responses.
What strategies do you use for dependency injection in iOS applications?
Strategies include initializer injection (preferred for testability), property injection (used for
optional dependencies), and service locators (less preferred due to hidden dependencies).
How do you debug memory leaks in iOS applications?
Use Xcode’s Instruments (Leaks & Memory Graph Debugger) to analyze retain cycles.
Utilize weak references in closures and properly deallocate objects to prevent leaks.
What are some ways to optimize the performance of a SwiftUI-based app?
Avoid excessive view recomputation, use @StateObject instead of @ObservedObject
when needed, optimize lists with @Identifiable , and leverage LazyVStack and
LazyHStack for better performance.
What are the trade-offs between using MVVM vs. VIPER vs. Redux-style state management?
MVVM is simpler and easier to adopt but can lead to bloated ViewModels. VIPER enforces
better separation of concerns but increases complexity. Redux provides unidirectional data
flow but requires careful state management.
How would you design an offline-first mobile app that syncs data when online?
Use Core Data or Realm for local storage, implement background sync tasks, use conflict resolution strategies, and track sync states efficiently.
If you had to scale an iOS app to support millions of users, what factors would you consider?
Optimize networking with caching and pagination, use background processing for heavy tasks, adopt efficient data storage strategies, and monitor performance with analytics tools.
Can you walk me through your most challenging project as an iOS developer?
M-payment Getnet
Tell me about a time you had to work under a tight deadline. How did you handle it?
Mention Xmas Hub, negotiation MVP
Have you ever disagreed with a technical decision in your team? How did you resolve it?
Of course, never considered any as a problem, everything in that matter is solved by conversations, rising pros and cons. Sometimes decisions are top down and we just need to live with them doing the best we can with we are given
How do you approach mentoring junior developers?
For me, patience is the key. they will require assistant, they will ask questions that may sound obvious but having in mind that is a process. I don’t usually like to give all at once, I help unlock when something isn’t progress but like to see them try even if it;s not always the best approach but is trying that we grow, by right or wrong.
Describe a time when you had to handle multiple priorities at once. How did you manage them?
Delegating in those situations is the best approach, if you can of course, otherwise, it must be raised that not always can be done at the same time for one person without the help and prioritise…
Tell me about a time you had to debug a critical issue in production. How did you approach it?
First try to get the device info, OS version, app version and steps to reproduce, then start investigating adding breaking points to points of interest
How would you explain memory management in Swift to a junior developer?
I could use the analogy to google spread sheet (class) and sending a microsoft excel sheet file through email(struct) and then explain from that the concept of class and struct and use this link to explain ARC.
Describe a time when you received negative feedback. How did you handle it?
If constructive, understand the points, take notes ask for suggestions for other peers and make a “roadmap” to improve my weak points
How do you ensure effective communication in a remote or distributed team?
Being available in core hours, if text is not being effective go for a quick call and being sure at the end the message was understood.
What steps do you take when onboarding into a new project or codebase?
Taking time to understand the working process, read the code to understand architectures, components, reausability, testing procedures, reading MRs, then picking up smaller questions at beginning if possible to put in action what I’ve been learning
Explain retain cycles in more depth. What’s the difference between weak and unowned?
weak references allow objects to be nil (typically used for delegate patterns).
unowned references assume the object will always exist, avoiding optionality (used
when one object outlives another).