Mark Client delegate as weak to match "delegate" pattern best practices and avoid probable retain cycles between Client and its Delegate (which would lead to a memory leak).
Having delegate parameter on the init method as an optional type helps to instantiate the Client itself as a non-optional property inside some other class init method, in case this class wants to be the delegate. Otherwise we could not pass self as a delegate diuring init process.
Mark Client delegate as
weak
to match "delegate" pattern best practices and avoid probable retain cycles between Client and its Delegate (which would lead to a memory leak).Having
delegate
parameter on the init method as an optional type helps to instantiate the Client itself as a non-optional property inside some other class init method, in case this class wants to be the delegate. Otherwise we could not passself
as a delegate diuringinit
process.