|
|
@@ -86,19 +86,19 @@ public class Reachability: NSObject {
|
|
|
|
|
|
// MARK: - *** Initialisation methods ***
|
|
|
|
|
|
- required public init?(reachabilityRef: SCNetworkReachability?) {
|
|
|
+ required public init(reachabilityRef: SCNetworkReachability) {
|
|
|
reachableOnWWAN = true
|
|
|
self.reachabilityRef = reachabilityRef
|
|
|
}
|
|
|
|
|
|
- public convenience init?(hostname: String) {
|
|
|
+ public convenience init(hostname: String) {
|
|
|
|
|
|
let nodename = (hostname as NSString).UTF8String
|
|
|
let ref = SCNetworkReachabilityCreateWithName(nil, nodename)
|
|
|
self.init(reachabilityRef: ref)
|
|
|
}
|
|
|
|
|
|
- public class func reachabilityForInternetConnection() -> Reachability? {
|
|
|
+ public class func reachabilityForInternetConnection() -> Reachability {
|
|
|
|
|
|
var zeroAddress = sockaddr_in()
|
|
|
zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
|
|
|
@@ -111,14 +111,14 @@ public class Reachability: NSObject {
|
|
|
return Reachability(reachabilityRef: ref)
|
|
|
}
|
|
|
|
|
|
- public class func reachabilityForLocalWiFi() -> Reachability? {
|
|
|
+ public class func reachabilityForLocalWiFi() -> Reachability {
|
|
|
|
|
|
var localWifiAddress: sockaddr_in = sockaddr_in(sin_len: __uint8_t(0), sin_family: sa_family_t(0), sin_port: in_port_t(0), sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
|
|
|
localWifiAddress.sin_len = UInt8(sizeofValue(localWifiAddress))
|
|
|
localWifiAddress.sin_family = sa_family_t(AF_INET)
|
|
|
|
|
|
// IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
|
|
|
- let address: Int64 = 0xA9FE0000
|
|
|
+ let address: UInt32 = 0xA9FE0000
|
|
|
localWifiAddress.sin_addr.s_addr = in_addr_t(address.bigEndian)
|
|
|
|
|
|
let ref = withUnsafePointer(&localWifiAddress) {
|
|
|
@@ -152,7 +152,7 @@ public class Reachability: NSObject {
|
|
|
if let reachabilityRef = reachabilityRef {
|
|
|
SCNetworkReachabilitySetCallback(reachabilityRef, nil, nil)
|
|
|
}
|
|
|
- reachabilityRef = nil
|
|
|
+ notifierRunning = false
|
|
|
}
|
|
|
|
|
|
// MARK: - *** Connection test methods ***
|