From the document, viewDidUnload
- "This method ... is your chance to do a final cleanup ..."
- "When a low memory condition occurs and the views of the current dispatcher view are not needed, the system may choose to remove these views from memory."
From the documentation, about the weak (semantics of the sample)
- Indicates that there is a weak (non-owning) connection with the target. If the target is freed, the property value is automatically set to nil .
So this is obvious. It does not apply to the object that your property points to, but simply nullifies your property based on the above rule for the weak.
ViewDidUnload assumes that your weak property cannot point to any object because this object is freed (depending on where viewDidUnload is in the View Controller life cycle). And just cleans it with zero.
This is safe for you, evident to weak rule and memory efficiency. The compiler cannot be sure that you have taken care of the pointed object. He just needs to provide cleaning.
source share