I just need to check the internet connection availability before start communicating with the service in my iphone App. I am using Swift 1.2 and Xcode 6 as my development en
An improved version of @Lachezar's answer for Swift2.x:
Alamofire.request(.POST, url).responseJSON { response in
switch response.result {
case .Success(let json):
// internet works.
case .Failure(let error):
if let err = error as? NSURLError where err == .NotConnectedToInternet {
// no internet connection
} else {
// other failures
}
}
}
If you would like the network status without parsing an URL, I suggest this solution: https://stackoverflow.com/a/38646078/706933