You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. Can you help me with my problem? I have always used this framework in my apps but now I can't figure out what I am doing wrong.
In my viewDidLoad() function I call this method:
//MARK: Reachability
func startReachability(){
//declare this property where it won't go out of scope relative to your listener
do{
let reachability = try Reachability.reachabilityForInternetConnection()
reachability.whenReachable = { reachability in
// this is called on a background thread, but UI updates must
// be on the main thread, like this:
dispatch_async(dispatch_get_main_queue()) {
if reachability.isReachableViaWiFi() {
print("Reachable via WiFi")
} else {
print("Reachable via Cellular")
}
}
}
reachability.whenUnreachable = { reachability in
// this is called on a background thread, but UI updates must
// be on the main thread, like this:
dispatch_async(dispatch_get_main_queue()) {
print("Not reachable")
}
}
try reachability.startNotifier()
} catch {
print("Unable to start notifier")
}
}
But it does not work. It calls whenReachable() and whenUnreachable() only once and when I turn Wi-Fi off and on it does nothing. I use 2.4 version.
The text was updated successfully, but these errors were encountered:
Hello. Can you help me with my problem? I have always used this framework in my apps but now I can't figure out what I am doing wrong.
In my viewDidLoad() function I call this method:
But it does not work. It calls whenReachable() and whenUnreachable() only once and when I turn Wi-Fi off and on it does nothing. I use 2.4 version.
The text was updated successfully, but these errors were encountered: