Daily iOS
Memory and ARC

Retain cycle example

Give me a concrete code example that creates a retain cycle, and fix it.

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

A closure stored by self that captures self forms a self → closure → self cycle; break it with a [weak self] capture list. A closure is a reference type that keeps captured references strongly in its heap context, so the moment you store it, both directions are strong.

Share a question