Why is NSURLConnection and CAAnimation delegate retained?

ios, ipad, iphone

Solution

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 `NSURLConnection` and `CAAnimation` however, 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.

Problem

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

Original source