iOS Developer
hardios-arc-memory-management

How does ARC work in iOS and what causes retain cycles?

Answer

ARC automatically manages reference counting for objects. Retain cycles happen when two objects strongly reference each other (common with closures and delegates). Fixes: - Use `weak`/`unowned` where appropriate - Break cycles in callbacks - Be careful with long-lived singletons capturing view controllers Interview tip: explain a closure capturing `self` inside a view controller and how to fix it.

Related Topics

SwiftMemoryiOS