I am using Alamofire 4.0.1 and I want to set a timeout for my request. I tried the solutions gived in this question:
In the first case
Based in @kamal-thakur response.
Swift 3:
var request = URLRequest(url: NSURL.init(string: "YOUR_URL") as! URL)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.timeoutInterval = 10 // 10 secs
let postString = "param1=\(var1)¶m2=\(var2)"
request.httpBody = postString.data(using: .utf8)
Alamofire.request(request).responseJSON {
response in
// do whatever you want here
}