@@ -56,6 +56,7 @@ public class Reachability: NSObject, Printable {
5656 public var whenReachable : NetworkReachable ?
5757 public var whenUnreachable : NetworkUneachable ?
5858 public var reachableOnWWAN : Bool
59+ public var notificationCenter = NSNotificationCenter . defaultCenter ( )
5960
6061 public var currentReachabilityStatus : NetworkStatus {
6162 if isReachable ( ) {
@@ -75,6 +76,12 @@ public class Reachability: NSObject, Printable {
7576 }
7677
7778 // MARK: - *** Initialisation methods ***
79+
80+ public required init ( reachabilityRef: SCNetworkReachability ) {
81+ reachableOnWWAN = true
82+ self . reachabilityRef = reachabilityRef
83+ }
84+
7885 public convenience init ( hostname: String ) {
7986 let ref = SCNetworkReachabilityCreateWithName ( nil , ( hostname as NSString ) . UTF8String) . takeRetainedValue ( )
8087 self . init ( reachabilityRef: ref)
@@ -203,11 +210,6 @@ public class Reachability: NSObject, Printable {
203210 } ( )
204211 private var previousReachabilityFlags : SCNetworkReachabilityFlags ?
205212
206- private init ( reachabilityRef: SCNetworkReachability ) {
207- reachableOnWWAN = true
208- self . reachabilityRef = reachabilityRef
209- }
210-
211213 func timerFired( ) {
212214 let currentReachabilityFlags = reachabilityFlags
213215 if let _previousReachabilityFlags = previousReachabilityFlags {
@@ -231,7 +233,7 @@ public class Reachability: NSObject, Printable {
231233 }
232234 }
233235
234- NSNotificationCenter . defaultCenter ( ) . postNotificationName ( ReachabilityChangedNotification, object: self )
236+ notificationCenter . postNotificationName ( ReachabilityChangedNotification, object: self )
235237 }
236238
237239 private func isReachableWithFlags( flags: SCNetworkReachabilityFlags ) -> Bool {
0 commit comments