0
With the swift3 update I’m having the following error "type 'Any' has on the Members subscriber", I’ve seen a lot of questions on the subject and tested most of them but without success. The code where I’m making this mistake 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()
}
}
Since the mistake is happening everywhere I do something like this self.Array[ind]["IsDefault"] as? Int
.
I did what I said but I still have the same error on the self lines. Array[Ind]["Isdefault"] as? Int and now in the code you said appears the following warning "Cast from 'JSON' to unrelated type ''[String: Anyobject] Always fails"
– HideCode