Checking internet connection in swift using Alamofire

import Foundation
import Alamofire
class Connectivity {
class func isConnectedToInternet() ->Bool {
return NetworkReachabilityManager()!.isReachable
}
}
if Connectivity.isConnectedToInternet() {
print("Yes! internet is available.")
// do some tasks..
}
import Foundation
import Alamofire
class Connectivity {
class var isConnectedToInternet:Bool {
return NetworkReachabilityManager()!.isReachable
}
}
if Connectivity.isConnectedToInternet {
print("Yes! internet is available.")
// do some tasks..
}

If you enjoyed reading this post, please share and recommend it so others can find it 💚💚💚💚💚💚 !!!!

--

--

--

iOS and tvOS developer, dreamer, photographer 🤨

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhimuralidharan

Abhimuralidharan

iOS and tvOS developer, dreamer, photographer 🤨

More from Medium

Swift Protocols

Closures in swift

[Swift] POP - Retroactive Modeling

How to convert Objc NSString “enum” to real Swift enum?