I had a problem after upgrading to the latest version of Alamofire 4.x, where myRequest.response (line 2) gives the error "Unable to call value of non-functional type" HTTPURLResponse? ". I have been using this code without any problems for some time. Can anyone help?
let queue = DispatchQueue(label: "com.cnoon.manager-response-queue", attributes: DispatchQueue.Attributes.concurrent) let myRequest = Alamofire.request(myURL, method: .get, headers: headers) myRequest.response ( queue: queue, responseSerializer: Request.JSONResponseSerializer(options: .allowFragments), completionHandler: { response in switch response.result { case .success: print(response.timeline) if let httpStatusCode = response.response?.statusCode { switch (httpStatusCode) { case 200: if let myValue = response.result.value { updateSuccessful = StorageMethod.sharedInstance.updateRoutine(JSON(myValue)) print(updateSuccessful) print("HERE") //print(myJSON) //let status_m = myJSON["dates"]["market_status"].stringValue //print(status_m) } case 401: customErrorMessage = "Session expired: Please exit app and re-login." updateSuccessful = false default: customErrorMessage = "Error: Please try again." updateSuccessful = false } } case .failure(let error): if error.code == -1009 { updateSuccessful = false customErrorMessage = error.localizedDescription } else { updateSuccessful = false customErrorMessage = error.localizedDescription + "Hi" } //print(error) } DispatchQueue.main.async { if (updateSuccessful) { self.refreshMasterData() } else { self.refreshMasterData() if let tabControl = self.tabBarController?.view { tabControl.makeToast(customErrorMessage, duration: 3.0, position: .center) } } if (self.refreshControl.isRefreshing) { self.showRefreshControl(false) } self.delegate?.portfolioTableViewControllerRefreshDrag(false) StorageMethod.sharedInstance.dataUpdating = false } } )
ios swift alamofire
dejavu89
source share