Alamofire错误更新到最新版本后

时间:2016-10-03 18:51:13

标签: ios swift alamofire

我在更新到最新版本的Alamofire 4.x后面临一个问题,其中myRequest.response(第2行)给出了错误'无法调用非函数类型的值' HTTPURLResponse ?&#39 ;.我一直在使用这段代码而没有任何问题。有人可以帮忙吗?

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
                }
            }

        )

0 个答案:

没有答案