With the update of swift3 I'm getting the following error "type 'Any' has no subscript members", I've seen lots of questions about it and tested most of them but to no avail. The code where I'm having this error is as follows:
Alamofire.request(mutableURLRequest)
.responseJSON{
response in
if let value: AnyObject = response.result.value as AnyObject? {
let json = JSON(value)
for (index, subJson) in json {
self.addressArray.add(subJson.object)
let ind: Int = Int(index)!
let defaultvalue: Int = self.Array[ind]["IsDefault"] as? Int
if(defaultvalue == 1)
{
let prefs: UserDefaults = UserDefaults.standard
let ID: Int = self.Array[ind]["ID"] as! Int
let Name: String = self.Array[ind]["Tag"] as! String
prefs.set(addressName, forKey: "Name")
prefs.set(addressID, forKey: “ID")
prefs.synchronize()
}
}
self.listAddress.reloadData()
}
}
Being that the error is everywhere I go in doing something like this self.Array[ind]["IsDefault"] as? Int
.