First, delegate uses the assign attribute instead of the retain attribute.
So why is it assign instead of retain?
In terms of memory management, the lifecycle of the delegate should not be controlled by the object. If the object uses retain, it is likely that the delegate cannot be correctly released.
Specifically, the following link is used:Assign is used to prevent cross-reference.
There are 3 classes .... A .. B .. c .. I am in .. create B... C .... and set C's delegate = self (that is, B ).. if the delegate in C is retain... then the retain of B will be + 2 (Class A is created + 1)
At this time .. if I release B in... then B's retain won't be 0 (because C's delegate is retain )... that is to say, B will never be released .. it cannot be released.
This memory leakage cannot be discovered by instrument.
NextArticleWell written! Let's take a look!
Link: http://www.robinlu.com/blog/archives/392