When I try to check for an internet connection on my iPhone I get a bunch of errors. Can anyone help me to fix this?
The code:
import Foundation
impo
If you are using Alamofire, you can do something like this:
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
configuration.timeoutIntervalForRequest = 15 //Set timeouts in sec
configuration.timeoutIntervalForResource = 15
let alamoFireManager = Alamofire.Manager(configuration:configuration)
alamoFireManager?.request(.GET, "https://yourURL.com", parameters: headers, encoding: .URL)
.validate()
.responseJSON { response in
if let error = response.result.error {
switch error.code{
case -1001:
print("Slow connection")
return
case -1009:
print("No Connection!")
return
default: break
}
}