Choosing weak vs unowned
When would you use unowned instead of weak?
When would you use unowned instead of weak?
Use unowned (no optional, no nil handling) when the target is guaranteed to outlive you or die with you, and weak when you aren't sure. A child referencing back to its parent, or a closure in a view referencing the view controller that owns it, are legitimate cases.
Memory and ARCShort answerAdvanced
This code, which loads an image asynchronously in a UITableView cell, crashes now and…
#unowned #lifetime #crash
Memory and ARCMultiple choiceAdvanced
In which of the following is a [unowned self] capture safe? Select all that apply.
#weak #unowned #lifetime
Memory and ARCMultiple choiceIntro
Which of the following statements about weak references are correct? Select all that…
#weak #unowned
Memory and ARCShort answerAdvanced
From the moment an object's last strong reference goes away until the memory is actually…
#weak #unowned