Right Way for changing timeoutIntervalForRequest in Alamofire

前端 未结 4 961
说谎
说谎 2021-01-19 17:23

I changed timeoutIntervalForRequest with

let manager = Alamofire.SessionManager.default
manager.session.configuration.timeoutIntervalForReq         


        
4条回答
  •  无人共我
    2021-01-19 18:11

    This worked for me :)

    let configuration = URLSessionConfiguration.default
    configuration.timeoutIntervalForRequest = TimeInterval(7)
    configuration.timeoutIntervalForResource = TimeInterval(7)
    let session = URLSession(configuration: configuration)
    
    let task = session.dataTask(with: url) {}
    

    Changes to the configuration of an already initialized URLSession have no effect, per Apple's documentation. If you want a custom timeout, either set the value on your requests, or create a custom URLSession with a custom configuration, as outlined in document

提交回复
热议问题