Daily iOS
Memory and ARC

ARC ownership and deallocation timing

In an iOS app written in Swift, how does ARC manage the lifetime of a class instance?

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

Each instance carries a strong reference count; the compiler inserts a retain when you assign or pass it and a release when it leaves scope or you assign nil, so the moment the count hits zero deinit runs and the memory is returned. weak and unowned don't raise this count.

Share a question