Handle timeout with Alamofire

后端 未结 9 1694
暗喜
暗喜 2020-12-01 05:24

Is it possible to add timeout handler for Alamofire request?

In my project I use Alamofire this way:

init() {
    let configuration = NSURLSessionCon         


        
9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 05:59

    Swift 3

    The accepted answer didn't work for me.

    After a lot of research, I did it like this:

    let manager = Alamofire.SessionManager.default
    manager.session.configuration.timeoutIntervalForRequest = 120
    
    manager.request("yourUrl", method: .post, parameters: ["parameterKey": "value"])
    

提交回复
热议问题