Procházet zdrojové kódy

Renaame Connection.none as Connection.unavailable

Ashley Mills před 6 roky
rodič
revize
5f86ee635c

+ 3 - 0
CHANGELOG.md

@@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 - Allow configuring the notification `DispatchQueue`, which was previously hardcoded to `DispatchQueue.main`. It is now an optional, which if set to `nil` will use the notifier's internal queue to fire notifications. The default is still `.main`
 ### Fixed
 - Fixed a crash which could occur if Reachability was deallocated at the same time a system thread was calling back into Reachability
+### Deprecated
+- `connection != .none` has been deprecated. Use `connection != .unavailable` instead.
+    
 
 ## [4.3.1] - 2018-10-18
 ### Fixed 

+ 1 - 41
README.md

@@ -20,46 +20,6 @@ And don't forget to **★** the repo. This increases its visibility and encourag
 Thanks
 Ash
 
-# IMPORTANT
-
-## Version 4.0 breaking changes
-
-### CocoaPods:
-
-If you're adding **Reachability.swift** using CocoaPods, note that the framework name has changed from `ReachabilitySwift` to `Reachability` (for consistency with Carthage)
-
-### Previously:
-
-```swift
-enum NetworkStatus {
-    case notReachable, reachableViaWiFi, reachableViaWWAN
-}
-var currentReachabilityStatus: NetworkStatus
-```
-
-### Now:
-
-```swift
-enum Connection {
-    case none, wifi, cellular
-}
-var connection: Connection
-```
-
-### Other changes:
-
-- `reachableOnWWAN` has been renamed to `allowsCellularConnection`
-
-- `reachability.currentReachabilityString` has been deprecated. Use `"\(reachability.connection)"` instead.
-
-- `isReachable` has been deprecated. Use `connection != .none` instead.
-
-- `isReachableViaWWAN` has been deprecated. Use `connection == .cellular` instead.
-
-- The notification for reachability changes has been renamed from `ReachabilityChangedNotification` to `Notification.Name.reachabilityChanged`
-
-- All closure callbacks and notification are fired on the main queue (including when `startNotifier()` is called)
-
 
 ## Got a problem?
 
@@ -177,7 +137,7 @@ and
       print("Reachable via WiFi")
   case .cellular:
       print("Reachable via Cellular")
-  case .none:
+  case .unavailable:
     print("Network not reachable")
   }
 }

+ 2 - 2
Reachability.xcodeproj/project.pbxproj

@@ -747,7 +747,7 @@
 				GCC_WARN_UNUSED_FUNCTION = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
-				MACOSX_DEPLOYMENT_TARGET = 10.10;
+				MACOSX_DEPLOYMENT_TARGET = 10.11;
 				MTL_ENABLE_DEBUG_INFO = YES;
 				ONLY_ACTIVE_ARCH = YES;
 				SDKROOT = iphoneos;
@@ -805,7 +805,7 @@
 				GCC_WARN_UNUSED_FUNCTION = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
-				MACOSX_DEPLOYMENT_TARGET = 10.10;
+				MACOSX_DEPLOYMENT_TARGET = 10.11;
 				MTL_ENABLE_DEBUG_INFO = NO;
 				SDKROOT = iphoneos;
 				SWIFT_VERSION = 5.0;

+ 1 - 1
ReachabilityMacSample/ViewController.swift

@@ -102,7 +102,7 @@ class ViewController: NSViewController {
     @objc func reachabilityChanged(_ note: Notification) {
         let reachability = note.object as! Reachability
         
-        if reachability.connection != .none {
+        if reachability.connection != .unavailable {
             updateLabelColourWhenReachable(reachability)
         } else {
             updateLabelColourWhenNotReachable(reachability)

+ 1 - 1
ReachabilitySample/ViewController.swift

@@ -102,7 +102,7 @@ class ViewController: UIViewController {
     @objc func reachabilityChanged(_ note: Notification) {
         let reachability = note.object as! Reachability
         
-        if reachability.connection != .none {
+        if reachability.connection != .unavailable {
             updateLabelColourWhenReachable(reachability)
         } else {
             updateLabelColourWhenNotReachable(reachability)

+ 11 - 7
Sources/Reachability.swift

@@ -61,12 +61,15 @@ public class Reachability {
     }
 
     public enum Connection: CustomStringConvertible {
-        case none, wifi, cellular
+        @available(*, deprecated, renamed: "unavailable")
+        case none
+        case unavailable, wifi, cellular
         public var description: String {
             switch self {
             case .cellular: return "Cellular"
             case .wifi: return "WiFi"
-            case .none: return "No Connection"
+            case .unavailable: return "No Connection"
+            case .none: return "unavailable"
             }
         }
     }
@@ -99,8 +102,9 @@ public class Reachability {
         }
         
         switch flags?.connection {
-        case .none?, nil: return .none
-        case .cellular?: return allowsCellularConnection ? .cellular : .none
+        case .unavailable?, nil: return .unavailable
+        case .none?: return .unavailable
+        case .cellular?: return allowsCellularConnection ? .cellular : .unavailable
         case .wifi?: return .wifi
         }
     }
@@ -230,7 +234,7 @@ public extension Reachability {
     // MARK: - *** Connection test methods ***
     @available(*, deprecated, message: "Please use `connection != .none`")
     var isReachable: Bool {
-        return connection != .none
+        return connection != .unavailable
     }
 
     @available(*, deprecated, message: "Please use `connection == .cellular`")
@@ -267,7 +271,7 @@ fileprivate extension Reachability {
     func notifyReachabilityChanged() {
         let notify = { [weak self] in
             guard let self = self else { return }
-            self.connection != .none ? self.whenReachable?(self) : self.whenUnreachable?(self)
+            self.connection != .unavailable ? self.whenReachable?(self) : self.whenUnreachable?(self)
             self.notificationCenter.post(name: .reachabilityChanged, object: self)
         }
 
@@ -281,7 +285,7 @@ extension SCNetworkReachabilityFlags {
     typealias Connection = Reachability.Connection
 
     var connection: Connection {
-        guard isReachableFlagSet else { return .none }
+        guard isReachableFlagSet else { return .unavailable }
 
         // If we're reachable, but not on an iOS device (i.e. simulator), we must be on WiFi
         #if targetEnvironment(simulator)