unowned access risk
A coworker wants to declare every delegate unowned instead of weak because unwrapping optionals is a hassle. Why isn't an unowned reference optional?
A coworker wants to declare every delegate unowned instead of weak because unwrapping optionals is a hassle. Why isn't an unowned reference optional?
unowned is a reference built on the promise that the target won't go away before you, so the runtime doesn't set it to nil when the target is deallocated; that's why it doesn't need to be optional, and if the promise breaks and you touch the deallocated target, you get an immediate trap instead of a nil check.
Memory and ARCShort answerAdvanced
From the moment an object's last strong reference goes away until the memory is actually…
#unowned #weak #arc
Memory and ARCMultiple choiceIntro
Which of the following statements about weak references are correct? Select all that…
#unowned #weak
Memory and ARCShort answerBasics
When would you use unowned instead of weak?
#unowned #weak
Memory and ARCMultiple choiceAdvanced
In which of the following is a [unowned self] capture safe? Select all that apply.
#unowned #weak