【发布时间】:2015-11-26 05:56:27
【问题描述】:
我有一个将 JSON 结果设置为 NSDictionary 的函数。然后它使用这个值来调用其他一些函数。我正在使用 Alamofire,并且由于我在 Swift 1 中编写了这个应用程序,所以这已经发生了一些变化,这给了我错误。
函数如下:
func fetchApiData() {
// I believe this is the problem code below.
let _requestURL1 = Alamofire.request(.GET,dataSourceURL!)
_requestURL1.responseJSON { (_requestUrl, _requestResponse, _objJSON1, error) -> Void in
if(_objJSON1 != nil)
{
let jsonResult1 = _objJSON1 as NSDictionary;
self.checkIP(jsonResult1)
self.checkGeo(jsonResult1)
}
else{
return
}
}
let _requestURL2 = Alamofire.request(.GET,self.dataSourceURL2!)
_requestURL2.responseJSON { (_requestUrl, _requestResponse, _objJSON2, error) -> Void in
if(_objJSON2 != nil)
{
let jsonResult2 = _objJSON2 as NSDictionary;
self.checkDNS(jsonResult2)
NSTimer.scheduledTimerWithTimeInterval(self.refreshFrequencyInt, target: self, selector: Selector("fetchApiData"), userInfo: nil, repeats: false)
}
else{
return
}
}
}
显然现在,这一行:
_requestURL1.responseJSON { (_requestUrl, _requestResponse, _objJSON1, error) -> Void in
给我这个错误:
'(_, _, _, _) -> Void' is not convertible to 'Response<AnyObject, NSError> -> Void'
我已经尝试过解决此问题的方法,但我似乎无法让代码以与以前相同的方式工作。
请帮忙! :)
【问题讨论】: