Jelajahi Sumber

Merge branch 'feature/ios10' of github.com:ashleymills/Reachability.swift into feature/ios10

Ashley Mills 9 tahun lalu
induk
melakukan
44a0cd5267
1 mengubah file dengan 42 tambahan dan 17 penghapusan
  1. 42 17
      README.md

+ 42 - 17
README.md

@@ -2,10 +2,47 @@
 
 Reachability.swift is a replacement for Apple's Reachability sample, re-written in Swift with closures.
 
-It is compatible with **iOS** (8.0 - 9.2), **OSX** (10.9 - 10.11) and **tvOS** (9.0 - 9.1)
+It is compatible with **iOS** (8.0 - 10.0), **OSX** (10.9 - 10.12) and **tvOS** (9.0 - 10.0)
 
 Inspired by https://github.com/tonymillion/Reachability
 
+#IMPORTANT - iOS 10 / Swift 3 / Breaking changes#
+
+The following iOS 10 branch contains the following breaking changes:
+
+Previously:
+```swift
+class func reachabilityForInternetConnection() throws
+```
+Now: 
+```swift
+init?()
+```
+
+Previously: 
+```swift
+init(hostname: String) throws
+```
+Now:
+```swift
+init?(hostname: String)
+```
+
+Previously:
+```swift
+public enum NetworkStatus: CustomStringConvertible {
+    case NotReachable, ReachableViaWiFi, ReachableViaWWAN
+}
+```
+Now:
+```swift
+public enum NetworkStatus: CustomStringConvertible {
+    case notReachable, reachableViaWiFi, reachableViaWWAN
+}
+```
+
+
+
 ## Supporting **Reachability.swift**
 Keeping **Reachability.swift** up-to-date is a time consuming task. Making updates, reviewing pull requests, responding to issues and answering emails all take time. If you'd like to help keep me motivated, please download my free app, [Foto Flipper] from the App Store. (To really motivate me, pay $0.99 for the IAP!)
 
@@ -63,14 +100,8 @@ To install Reachability.swift with Carthage:
 ## Example - closures
 
 ```swift
-let reachability: Reachability
-do {
-    reachability = try Reachability.reachabilityForInternetConnection()
-} catch {
-    print("Unable to create Reachability")
-    return
-}
-
+//declare this property where it won't go out of scope relative to your listener
+let reachability = Reachability()!
 
 reachability.whenReachable = { reachability in
     // this is called on a background thread, but UI updates must
@@ -110,19 +141,13 @@ This sample will use `NSNotification`s to notify when the interface has changed.
 
 ```swift
 //declare this property where it won't go out of scope relative to your listener
-var reachability: Reachability?
+let reachability = Reachability()!
 
 //declare this inside of viewWillAppear
-do {
-      reachability = try Reachability.reachabilityForInternetConnection()
-    } catch {
-      print("Unable to create Reachability")
-      return
-    }
 
     NSNotificationCenter.defaultCenter().addObserver(self, selector: "reachabilityChanged:",name: ReachabilityChangedNotification,object: reachability)
     do{
-      try reachability?.startNotifier()
+      try reachability.startNotifier()
     }catch{
       print("could not start reachability notifier")
     }