How does ARC work and when do retain cycles occur?
The idea
ARC (Automatic Reference Counting) — the compiler inserts retain/release where strong references to a class instance appear and disappear. The count lives in the object header; when it drops to zero, deinit runs and the memory is freed — deterministically, with no garbage collector. ARC applies only to classes (and to closures, whose context is also a heap object); structs and enums are simply copied.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep