Network reachability status monitoring on iOS (Part 2)
Sauvik Dolui
44715

Hi, question, since you only have 1 funcion in your delegate, couldn’t you just add a closure function to your list of listners? You would then don’t need a delegate and protocol. You only need to add code like this:

ReachabilityManager.shared.addListener { status in

switch status {

case .notReachable:

debugPrint(“ViewController: Network became unreachable”)

case .reachableViaWiFi:

debugPrint(“ViewController: Network reachable through WiFi”)

case .reachableViaWWAN:

debugPrint(“ViewController: Network reachable through Cellular Data”)

}

}

Like what you read? Give Edwin Vermeer a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.