Set timeout in Alamofire

后端 未结 14 1147
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 03:33

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

14条回答
  •  有刺的猬
    2020-12-01 03:59

    Alamofire 5.1 includes a new way to modify the request with a closure in the initializer:

    AF.request(url) { $0.timeoutInterval = 60 }
        .validate()
        .response { _ in // handle response here }
    

提交回复
热议问题