Sfoglia il codice sorgente

Use new DispatchTimeInterval enum with DispatchTime struct

Rob Goble 9 anni fa
parent
commit
d9333c19fb
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      ReachabilitySample/ViewController.swift

+ 2 - 2
ReachabilitySample/ViewController.swift

@@ -24,13 +24,13 @@ class ViewController: UIViewController {
         startNotifier()
 
         // After 5 seconds, stop and re-start reachability, this time using a hostname
-        let dispatchTime = DispatchTime.now() + Double(Int64(UInt64(5) * NSEC_PER_SEC)) / Double(NSEC_PER_SEC)
+        let dispatchTime = DispatchTime.now() + DispatchTimeInterval.seconds(5)
         DispatchQueue.main.after(when: dispatchTime) {
             self.stopNotifier()
             self.setupReachability(hostName: "google.com", useClosures: true)
             self.startNotifier()
 
-            let dispatchTime = DispatchTime.now() + Double(Int64(UInt64(5) * NSEC_PER_SEC)) / Double(NSEC_PER_SEC)
+            let dispatchTime = DispatchTime.now() + DispatchTimeInterval.seconds(5)
             DispatchQueue.main.after(when: dispatchTime) {
                 self.stopNotifier()
                 self.setupReachability(hostName: "invalidhost", useClosures: true)