Я переписываю существующий код Objective-C (iOS) в Swift и теперь сталкиваюсь с некоторыми проблемами с классом Reachability
Apple для проверки доступности сети... В моем существующем коде я использую следующее для достижения этого.
var reachability: Reachability = Reachability.reachabilityForInternetConnection()
var internetStatus:NetworkStatus = reachability.currentReachabilityStatus()
if (internetStatus != NotReachable) {
//my web-dependent code
}
else {
//There-is-no-connection warning
}
И я получаю эту ошибку: network status is not convertible to string
в этой строке:
if (internetStatus != NotReachable)
Есть ли способ или класс для получения статуса сети?
Мне нужны эти три условия:
NotReachable: Obviously, there’s no Internet connection
ReachableViaWiFi: Wi-Fi connection
ReachableViaWWAN: 3G or 4G connection