14 Mar 2012, 22:30
Generic-user-small

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
Generic-user-small

Laurence Rochfort (4 posts)

I would like some explanation too, please.

17 Apr 2013, 15:25
6ec88fb092a2aad93c7af6d645fff57a_pragsmall

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. http://stackoverflow.com/questions/8449040/why-use-weak-pointer-for-delegation

  You must be logged in to comment