소스 검색

Update readme

Ashley Mills 8 년 전
부모
커밋
177dab8e69
1개의 변경된 파일8개의 추가작업 그리고 11개의 파일을 삭제
  1. 8 11
      README.md

+ 8 - 11
README.md

@@ -113,13 +113,13 @@ NOTE: All closures are run on the **main queue**.
 let reachability = Reachability()!
 
 reachability.whenReachable = { reachability in
-    if reachability.isReachableViaWiFi {
+    if reachability.connection == .wifi {
         print("Reachable via WiFi")
     } else {
         print("Reachable via Cellular")
     }
 }
-reachability.whenUnreachable = { reachability in
+reachability.whenUnreachable = { _ in
     print("Not reachable")
 }
 
@@ -146,7 +146,7 @@ let reachability = Reachability()!
 
 //declare this inside of viewWillAppear
 
-     NotificationCenter.default.addObserver(self, selector: #selector(self.reachabilityChanged),name: ReachabilityChangedNotification,object: reachability)
+     NotificationCenter.default.addObserver(self, selector: #selector(reachabilityChanged(_:)), name: .reachabilityChanged, object: reachability)
     do{
       try reachability.startNotifier()
     }catch{
@@ -161,13 +161,12 @@ func reachabilityChanged(note: Notification) {
 
   let reachability = note.object as! Reachability
 
-  if reachability.isReachable {
-    if reachability.isReachableViaWiFi {
+  switch reachability.connection {
+  case .wifi:
       print("Reachable via WiFi")
-    } else {
+  case .cellular:
       print("Reachable via Cellular")
-    }
-  } else {
+  case .none:
     print("Network not reachable")
   }
 }
@@ -177,9 +176,7 @@ and for stopping notifications
 
 ```swift
 reachability.stopNotifier()
-NotificationCenter.default.removeObserver(self,
-                                          name: ReachabilityChangedNotification,
-                                          object: reachability)
+NotificationCenter.default.removeObserver(self, name: .eachabilityChanged, object: reachability)
 ```
 
 ## Want to help?