|
|
@@ -116,32 +116,23 @@ public class NetworkReachabilityManager {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- Creates a `NetworkReachabilityManager` instance with the default socket IPv4 or IPv6 address.
|
|
|
+ Creates a `NetworkReachabilityManager` instance that monitors the address 0.0.0.0.
|
|
|
+
|
|
|
+ Reachability treats the 0.0.0.0 address as a special token that causes it to monitor the general routing
|
|
|
+ status of the device, both IPv4 and IPv6.
|
|
|
|
|
|
- returns: The new `NetworkReachabilityManager` instance.
|
|
|
- */
|
|
|
+ */
|
|
|
public convenience init?() {
|
|
|
- if #available(iOS 9.0, OSX 10.10, *) {
|
|
|
- var address = sockaddr_in6()
|
|
|
- address.sin6_len = UInt8(sizeofValue(address))
|
|
|
- address.sin6_family = sa_family_t(AF_INET6)
|
|
|
-
|
|
|
- guard let reachability = withUnsafePointer(&address, {
|
|
|
- SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
|
|
|
- }) else { return nil }
|
|
|
-
|
|
|
- self.init(reachability: reachability)
|
|
|
- } else {
|
|
|
- var address = sockaddr_in()
|
|
|
- address.sin_len = UInt8(sizeofValue(address))
|
|
|
- address.sin_family = sa_family_t(AF_INET)
|
|
|
-
|
|
|
- guard let reachability = withUnsafePointer(&address, {
|
|
|
- SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
|
|
|
- }) else { return nil }
|
|
|
-
|
|
|
- self.init(reachability: reachability)
|
|
|
- }
|
|
|
+ var address = sockaddr_in()
|
|
|
+ address.sin_len = UInt8(sizeofValue(address))
|
|
|
+ address.sin_family = sa_family_t(AF_INET)
|
|
|
+
|
|
|
+ guard let reachability = withUnsafePointer(&address, {
|
|
|
+ SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
|
|
|
+ }) else { return nil }
|
|
|
+
|
|
|
+ self.init(reachability: reachability)
|
|
|
}
|
|
|
|
|
|
private init(reachability: SCNetworkReachability) {
|