Can someone explain when and when not to use a \'weak\' assignment to a delegate pointer in Swift, and why?
My understanding is that if you use a protocol that is n
Delegates should (edit: generally) always be weak.
Lets say b is the delegate of a. Now a's delegate property is b.
In a case where you want b to release when c is gone
If c holds a strong reference to b and c deallocates, you want b to deallocate with c. However, using a strong delegate property in a, b will never get deallocated since a is holding on to b strongly. Using a weak reference, as soon as b loses the strong reference from c, b will dealloc when c deallocs.
Usually this is the intended behaviour, which is why you would want to use a weak property.