I am writing the swift version of the accepted answer here, incase if someone finds it usefull, the code is written swift 2,
You can download the required files from SampleCode
Add Reachability.h
and Reachability.m
file to your project,
Now one will need to create Bridging-Header.h
file if none exists for your project,
Inside your Bridging-Header.h
file add this line :
#import "Reachability.h"
Now in order to check for Internet Connection
static func isInternetAvailable() -> Bool {
let networkReachability : Reachability = Reachability.reachabilityForInternetConnection()
let networkStatus : NetworkStatus = networkReachability.currentReachabilityStatus()
if networkStatus == NotReachable {
print("No Internet")
return false
} else {
print("Internet Available")
return true
}
}