midiOS
Weak vs Unowned references
Updated May 6, 2026
Short answer
Both prevent retain cycles, but weak is optional and unowned is non-optional.
Deep explanation
weak becomes nil automatically; unowned assumes lifetime safety.
Real-world example
Delegates use weak references.
Common mistakes
- Using unowned when object may deallocate.
Follow-up questions
- When to prefer weak over unowned?
- What is retain cycle?