I am rewriting my existing Objective-C code (iOS) to Swift and now am facing some issues with the Reachability
class of Apple for checking network availability... In my existing code I am using the following for achieving that.
var reachability: Reachability = Reachability.reachabilityForInternetConnection()
var internetStatus:NetworkStatus = reachability.currentReachabilityStatus()
if (internetStatus != NotReachable) {
//my web-dependent code
}
else {
//There-is-no-connection warning
}
And I am getting this error: network status is not convertible to string
at this line:
if (internetStatus != NotReachable)
Is there a method or class for getting network status?
I need these three conditions:
NotReachable: Obviously, there’s no Internet connection
ReachableViaWiFi: Wi-Fi connection
ReachableViaWWAN: 3G or 4G connection
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…