File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ protocol MQTTSessionStreamDelegate: class {
16
16
17
17
class MQTTSessionStream : NSObject {
18
18
19
- private var currentRunLoop : RunLoop !
19
+ private var currentRunLoop : RunLoop ?
20
20
private let inputStream : InputStream ?
21
21
private let outputStream : OutputStream ?
22
22
private var sessionQueue : DispatchQueue
@@ -48,8 +48,8 @@ class MQTTSessionStream: NSObject {
48
48
}
49
49
50
50
self . currentRunLoop = RunLoop . current
51
- inputStream? . schedule ( in: self . currentRunLoop, forMode: . defaultRunLoopMode)
52
- outputStream? . schedule ( in: self . currentRunLoop, forMode: . defaultRunLoopMode)
51
+ inputStream? . schedule ( in: self . currentRunLoop! , forMode: . defaultRunLoopMode)
52
+ outputStream? . schedule ( in: self . currentRunLoop! , forMode: . defaultRunLoopMode)
53
53
54
54
inputStream? . open ( )
55
55
outputStream? . open ( )
@@ -63,12 +63,13 @@ class MQTTSessionStream: NSObject {
63
63
self . connectTimeout ( )
64
64
}
65
65
}
66
- self . currentRunLoop. run ( )
66
+ self . currentRunLoop! . run ( )
67
67
}
68
68
}
69
69
70
70
deinit {
71
71
delegate = nil
72
+ guard let currentRunLoop = currentRunLoop else { return }
72
73
inputStream? . close ( )
73
74
inputStream? . remove ( from: currentRunLoop, forMode: . defaultRunLoopMode)
74
75
outputStream? . close ( )
You can’t perform that action at this time.
0 commit comments