J'utilise dataTaskWithRequest et j'obtiens json de tableau avec deux objets dedans (ces objets sont clé, valeur) et je veux vérifier une valeur de clé dans deux objets.type (chaîne, anyobject) n'a aucun membre indice
ceci est mon code:
let task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
print("Response: \(response)")
var jsonArray: [String:AnyObject]!
do {
jsonArray = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions()) as? [String:AnyObject]
} catch {
print(error)
}
for json in jsonArray {
print("object json reciver :",json)
//type (string , anyobject) has no subscript member
print("state :",json["state"])
}
})
Ce que vous appelez jsonArray n'est pas un tableau, c'est un dictionnaire. – Moritz