IntermediateTechnical
Explain how ARC works in Swift and describe a scenario where you might create a retain cycle in an iOS app. How would you detect and fix it?
iOS Developer
General

Sample Answer

ARC (Automatic Reference Counting) tracks strong references to objects and deallocates them when their reference count reaches zero. In Swift, classes are reference types, so strong references between them can create retain cycles where neither object is released. A common scenario is a view controller holding a strong reference to a closure property, and that closure capturing `self` strongly. For example, a network manager callback or a timer closure that uses `self` inside without a capture list can cause the view controller to never deallocate. To detect this, I’d use Xcode’s Memory Graph Debugger to see if view controllers stay in memory after dismissal, and add deinit logs to confirm. Instruments’ Leaks tool can also help. To fix it, I’d use `[weak self]` or `[unowned self]` in the closure capture list, depending on the lifecycle guarantees, and ensure delegates are `weak` where appropriate. After the fix, I’d repeat the memory profiling and verify that `deinit` is called and the view controller is no longer retained.

Keywords

Basic explanation of ARCDefinition of retain cyclesConcrete example (VC + closure/delegate)Use of debugging tools (Memory Graph, Instruments)Use of weak/unowned to resolve
Related Questions

Walk me through a recent multi-channel digital marketing campaign you managed end-to-end. How did you set objectives, choose channels, allocate budget, and measure success?

IntermediateBEHAVIORAL

In your resume you note improving or optimizing [a process, KPI, or metric]. What specific baseline metrics did you start from, what steps did you personally take, and how did you verify that the improvement was due to your changes rather than external factors?

IntermediatePROBLEM_SOLVING

Based on your hydrology and irrigation engineering background, explain how you would estimate the irrigation water requirement for a kharif crop in a semi-arid region of Gujarat. Walk me through each step: from reference evapotranspiration estimation, crop coefficient selection, effective rainfall calculation, to arriving at canal discharge for a given command area.

IntermediateTECHNICAL

In your civil engineering studies, what specific design coursework or project work did you complete related to irrigation channels or canals (e.g., design of lined/unlined canals, distributaries, minors)? Describe one such design in detail, including how you determined discharge, permissible velocity, section dimensions, and lining choice for Gujarat-type soil and climate conditions.

IntermediateTECHNICAL

On your resume you mention working on a cross-functional project (e.g., involving multiple teams or stakeholders). Describe a situation from that project where priorities conflicted—how did you navigate the trade-offs and what was the final outcome?

IntermediateSITUATIONAL