Alamofire Error Domain=NSURLErrorDomain Code=-999 “cancelled”

前端 未结 5 1224
既然无缘
既然无缘 2021-01-05 14:15

I already have successfully got keychain for my token and passing it to AccessTokenAdapter class shown below. http127.0.0.1:8000/api2/projects/?format=json is passed as proj

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-05 14:57

    This error usually caused by the SessionManager you created falling out of scope and being deinited, and your requests will be cancelled. Keep a reference to it, my solution is using a variable to store SessionManager in your APIService class

      public lazy var sharedManager: SessionManager = {
        let configuration = URLSessionConfiguration.default
    
        configuration.timeoutIntervalForRequest = 60
        configuration.timeoutIntervalForResource = 60
    
        let manager = Alamofire.SessionManager(configuration: configuration)
        return manager
    }()
    

提交回复
热议问题