Skip to content

Instantly share code, notes, and snippets.

@sauvikatinnofied
Last active January 19, 2017 15:09
Show Gist options
  • Save sauvikatinnofied/e0eeb5bf440bc900cb82e9540f23132c to your computer and use it in GitHub Desktop.
Save sauvikatinnofied/e0eeb5bf440bc900cb82e9540f23132c to your computer and use it in GitHub Desktop.
Medium Blog Post Code Snippet
/// 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