As asked
How does Automatic Reference Counting work in Swift, and what are the three most common patterns that produce retain cycles in real iOS codebases? Walk me through how you detect and fix each one.
Sample answer outline
A strong answer explains that ARC inserts retain/release calls at compile time rather than runtime, then covers delegate cycles (strong delegate property), closure captures (capturing self strongly inside a stored closure on self), and parent-child object graphs (two objects holding strong references to each other). Candidate should name weak and unowned, explain when each is safe, and mention the Memory Graph Debugger or Instruments Allocations to detect leaking objects.
Expect these follow-ups
- When is unowned safer than weak, and what crashes can unowned produce?
- How does capture list syntax change when you have multiple captured variables?