Last active
January 19, 2017 15:09
-
-
Save sauvikatinnofied/e0eeb5bf440bc900cb82e9540f23132c to your computer and use it in GitHub Desktop.
Medium Blog Post Code Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Called whenever there is a change in NetworkReachibility Status | |
/// | |
/// — parameter notification: Notification with the Reachability instance | |
func reachabilityChanged(notification: Notification) { | |
let reachability = notification.object as! Reachability | |
switch reachability.currentReachabilityStatus { | |
case .notReachable: | |
debugPrint("Network became unreachable") | |
case .reachableViaWiFi: | |
debugPrint("Network reachable through WiFi") | |
case .reachableViaWWAN: | |
debugPrint("Network reachable through Cellular Data") | |
} | |
// Sending message to each of the delegates | |
for listener in listeners { | |
listener.networkStatusDidChange(status: reachability.currentReachabilityStatus) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment