File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -38,14 +38,24 @@ open class PusherConnection: NSObject {
38
38
39
39
open lazy var reachability : Reachability ? = {
40
40
let reachability = Reachability . init ( )
41
- reachability? . whenReachable = { [ unowned self] reachability in
42
- self . delegate? . debugLog ? ( message: " [PUSHER DEBUG] Network reachable " )
43
- if self . connectionState == . disconnected || self . connectionState == . reconnectingWhenNetworkBecomesReachable {
44
- self . attemptReconnect ( )
41
+ reachability? . whenReachable = { [ weak self] reachability in
42
+ guard self != nil else {
43
+ print ( " Your Pusher instance has probably become deallocated. See https://github.com/pusher/pusher-websocket-swift/issues/109 for more information " )
44
+ return
45
+ }
46
+
47
+ self !. delegate? . debugLog ? ( message: " [PUSHER DEBUG] Network reachable " )
48
+ if self !. connectionState == . disconnected || self !. connectionState == . reconnectingWhenNetworkBecomesReachable {
49
+ self !. attemptReconnect ( )
45
50
}
46
51
}
47
- reachability? . whenUnreachable = { [ unowned self] reachability in
48
- self . delegate? . debugLog ? ( message: " [PUSHER DEBUG] Network unreachable " )
52
+ reachability? . whenUnreachable = { [ weak self] reachability in
53
+ guard self != nil else {
54
+ print ( " Your Pusher instance has probably become deallocated. See https://github.com/pusher/pusher-websocket-swift/issues/109 for more information " )
55
+ return
56
+ }
57
+
58
+ self !. delegate? . debugLog ? ( message: " [PUSHER DEBUG] Network unreachable " )
49
59
}
50
60
return reachability
51
61
} ( )
You can’t perform that action at this time.
0 commit comments