i am new to ios development. I just came to know that their are two delegates in Foundation that are retained. My understanding says that a delegate must always be loosely coupled. So why these two are specifically retained?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Commonly, a delegate is needed for the entire lifetime of an object, which is why it is usually a weak/non-retained reference. Otherwise, neither the object nor the delegate could ever be deallocated, because they would both wait for the other to go away.
In the case of
NSURLConnectionandCAAnimationhowever, the delegate is actually only needed for a specific task that has some sort of “finished” state. When the connection finishes loading/is cancelled or the animation has reached its end, they can just release the delegate themselves and thus break the retain cycle.