Permalink
Browse files

[Issue #1809] Moved the NetworkReachabilityManager back to public ACL.

This class was never intended to be subclassable. It was incorrectly made open and should have always been public instead. Proxying can be done at the app levels using protocol rather than subclassing.
  • Loading branch information...
1 parent 0419c66 commit 779930c399307caa3d1afb01fd628754e323ea34 @cnoon cnoon committed Dec 19, 2016
Showing with 9 additions and 19 deletions.
  1. +9 −19 Source/NetworkReachabilityManager.swift
@@ -33,17 +33,7 @@ import SystemConfiguration
/// Reachability can be used to determine background information about why a network operation failed, or to retry
/// network requests when a connection is established. It should not be used to prevent a user from initiating a network
/// request, as it's possible that an initial request may be required to establish reachability.
-open class NetworkReachabilityManager {
- /**
- Defines the various states of network reachability.
-
- - Unknown: It is unknown whether the network is reachable.
- - NotReachable: The network is not reachable.
- - ReachableOnWWAN: The network is reachable over the WWAN connection.
- - ReachableOnWiFi: The network is reachable over the WiFi connection.
- */
-
-
+public class NetworkReachabilityManager {
/// Defines the various states of network reachability.
///
/// - unknown: It is unknown whether the network is reachable.
@@ -71,25 +61,25 @@ open class NetworkReachabilityManager {
// MARK: - Properties
/// Whether the network is currently reachable.
- open var isReachable: Bool { return isReachableOnWWAN || isReachableOnEthernetOrWiFi }
+ public var isReachable: Bool { return isReachableOnWWAN || isReachableOnEthernetOrWiFi }
/// Whether the network is currently reachable over the WWAN interface.
- open var isReachableOnWWAN: Bool { return networkReachabilityStatus == .reachable(.wwan) }
+ public var isReachableOnWWAN: Bool { return networkReachabilityStatus == .reachable(.wwan) }
/// Whether the network is currently reachable over Ethernet or WiFi interface.
- open var isReachableOnEthernetOrWiFi: Bool { return networkReachabilityStatus == .reachable(.ethernetOrWiFi) }
+ public var isReachableOnEthernetOrWiFi: Bool { return networkReachabilityStatus == .reachable(.ethernetOrWiFi) }
/// The current network reachability status.
- open var networkReachabilityStatus: NetworkReachabilityStatus {
+ public var networkReachabilityStatus: NetworkReachabilityStatus {
guard let flags = self.flags else { return .unknown }
return networkReachabilityStatusForFlags(flags)
}
/// The dispatch queue to execute the `listener` closure on.
- open var listenerQueue: DispatchQueue = DispatchQueue.main
+ public var listenerQueue: DispatchQueue = DispatchQueue.main
/// A closure executed when the network reachability status changes.
- open var listener: Listener?
+ public var listener: Listener?
private var flags: SCNetworkReachabilityFlags? {
var flags = SCNetworkReachabilityFlags()
@@ -151,7 +141,7 @@ open class NetworkReachabilityManager {
///
/// - returns: `true` if listening was started successfully, `false` otherwise.
@discardableResult
- open func startListening() -> Bool {
+ public func startListening() -> Bool {
var context = SCNetworkReachabilityContext(version: 0, info: nil, retain: nil, release: nil, copyDescription: nil)
context.info = Unmanaged.passUnretained(self).toOpaque()
@@ -175,7 +165,7 @@ open class NetworkReachabilityManager {
}
/// Stops listening for changes in network reachability status.
- open func stopListening() {
+ public func stopListening() {
SCNetworkReachabilitySetCallback(reachability, nil, nil)
SCNetworkReachabilitySetDispatchQueue(reachability, nil)
}

0 comments on commit 779930c

Please sign in to comment.