centrifugal / centrifuge-swift

Swift client SDK for bidirectional real-time communication with Centrifugo and Centrifuge-based server over WebSocket
MIT License
47 stars 41 forks source link

Mark Client delegate as `weak` and make it optional #2

Closed fedulvtubudul closed 5 years ago

fedulvtubudul commented 5 years ago

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.