Alamofire火变量类型没有下标成员 [英] Alamofire fire variable type has no subscript members
本文介绍了Alamofire火变量类型没有下标成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
更新到Alamofire 4并将我的代码更新为Swift 3后,我的所有请求都因某些原因无效。我尝试使用的变量以红色突出显示并说Type Any'没有下标成员
After updating to Alamofire 4 and updating my code to Swift 3, all of my requests are not working for some reason. The variables that I am trying to utilize are highlighted in red and say "Type Any' has no subscript members"
这是我的代码:
Alamofire.request("https://example.com/notifications.php?action=\(action)&UUID=\(UniversalUUID)&token=\(token)").responseJSON{ (response) -> Void in
if let JSON = response.result.value{
let message = JSON["message"] as! String
print(message)
}
推荐答案
您需要添加吗? [String:Any]
Alamofire.request(yourURL).responseJSON { (response) in
switch response.result {
case .success:
if let JSON = response.result.value as? [String: Any] {
let message = JSON["message"] as! String
print(message)
}
case .failure(let error):
// error handling
}
}
这篇关于Alamofire火变量类型没有下标成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文