Ios 调用api(alamofire)时获取nil值
我正在使用alamofire调用api。但在这个特定的api中,我得到了nil值作为响应。实际上,当我在浏览器中使用api时,它运行得非常好 这是我的密码Ios 调用api(alamofire)时获取nil值,ios,swift,swift2,ios9,alamofire,Ios,Swift,Swift2,Ios9,Alamofire,我正在使用alamofire调用api。但在这个特定的api中,我得到了nil值作为响应。实际上,当我在浏览器中使用api时,它运行得非常好 这是我的密码 func web() { request(.GET, "http://www.horecasupply.nl/AJAX?function=appStructure", parameters: nil, encoding: .JSON).responseJSON { (response : Response<AnyObjec
func web()
{
request(.GET, "http://www.horecasupply.nl/AJAX?function=appStructure", parameters: nil, encoding: .JSON).responseJSON { (response : Response<AnyObject, NSError>) -> Void in
if response.result.value != nil {
print(response.result.value)
}
}
}
编辑1::尝试了responsestring而不是responsejson。
但是得到的是不同的反应,那么我如何转换呢
\r\n\r\n\r\n\r\n\r\n DD\u belatedPNG.fix(\'img,.png\u bg\')//修复任何或.png\u bg背景图像\r\n\r\n\r\n\r\n-->\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
尝试一下这段代码,这应该可以:
Alamofire.request(.GET, "http://www.horecasupply.nl/AJAX?function=appStructure").responseJSON { response in
if response.result.value != nil {
print(response.result.value)
}
}
尝试使用
responseString
而不是responseJson
,通过使用responseString获取此类响应\r\n\r\n\r\n\r\n\r\n DD\u belatedPNG.fix(\'img,.png\u bg\)//修复任何或.png\u bg背景图像\r\n\r\n\r\n\r\n\r\n-->\r\n\r\n\r\n\r\n\r\n\r\n\r\n)我运行了与您发布的代码相同的代码&它工作正常。我得到的响应与浏览器相同。您使用的是哪个xcode?Poojathoraty你的代码片段对我有用()。为什么?怎么用?OP的代码对我有用,为什么你认为用你的代码替换它会改善他们的情况?请解释你的答案。
Alamofire.request(.GET, "http://www.horecasupply.nl/AJAX?function=appStructure").responseJSON { response in
if response.result.value != nil {
print(response.result.value)
}
}