small medium large xlarge

14 Mar 2012, 22:30
Jerry Howard (1 post)

Avoiding the circular reference, my feeling is to have the weak attribute for the delegate property, but I really don’t know why. Could you explain a bit?

18 Dec 2012, 14:47
Laurence Rochfort (4 posts)

I would like some explanation too, please.

17 Apr 2013, 15:25
Yong Bakos (5 posts)

A should own B, such that, say, when A is dealloc’d, B is also dealloc’d. In other words, when A goes away, we want ARC to automatically get rid of the “things that A owns.”

However, considering B’s reference to A as a delegate, we don’t want B to have a strong reference to A. If we did, I believe the underlying retain count would be too high for A.

As a rule of thumb, delegates should be weak.

You must be logged in to comment