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

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”)

}

}

Show your support

Clapping shows how much you appreciated Edwin Vermeer’s story.