alamofire和alamofireobjectmapper等待同步

时间:2019-06-30 14:09:49

标签: swift alamofire alamofireobjectmapper

我正在使用alamfire来执行http请求,我也曾经使用过alamofireobjectmapper将Json转换为对象,代码成功,但是现在,我一直在等待请求完成,这是我的代码: func loadData(){         让url =“ someUrl”

    let parameterArray:[String: Any] = jsonHandle.toFarmDetailsJson(farmCode: self.farmCode!)
    let encoding:URLEncoding = .default
    Alamofire.request( url, method: .post, parameters: parameterArray, encoding: encoding )
        .responseObject(queue: nil,
                        keyPath: nil,
                        mapToObject: nil,
                        context: nil,
                        completionHandler: { (response :DataResponse<FarmList>) ->Void in
                            if let result = response.result.value{
                                self.farmList = [result]
                            }

        })

}

0 个答案:

没有答案