Checking internet connection in swift using Alamofire

I am seeing medium.com as a medium to save my code in remote so that it is accessible from anywhere. This may or may not be helpful for others. :-)

For swift 3+ and Alamofire 4.4 , I created a swift class called Connectivity . You can use NetworkReachabilityManager class from Alamofire and configure the isConnectedToInternet() method as per your need. I am only checking if the device is connected to internet or not.

Usage:

EDIT: Since swift is encouraging computed properties, you can change the above function like:

and use it like:

Thanks. !

iOS and tvOS developer, dreamer, photographer 🤨

iOS and tvOS developer, dreamer, photographer 🤨