Hello à tous,
J’ai un soucis avec Alamofire, ou plutôt avec l’exploration d’un Json. Je commence à m’arracher les cheveux (déjà que j’en ai pas beaucoup… )
En gros, voici la structure du Json :
{
“nbItems”:10,
“data”:[
{ “id”:1, “title”:“Mon titre”, “link”:“http://xxxx.fr” },
{ “id”:2, “title”:“Mon titre”, “link”:“http://xxxx.fr” },
{ “id”:3, “title”:“Mon titre”, “link”:“http://xxxx.fr” },
{ “id”:4, “title”:“Mon titre”, “link”:“http://xxxx.fr” },
{ “id”:5, “title”:“Mon titre”, “link”:“http://xxxx.fr” },
{ “id”:6, “title”:“Mon titre”, “link”:“http://xxxx.fr” },
{ “id”:7, “title”:“Mon titre”, “link”:“http://xxxx.fr” },
{ “id”:8, “title”:“Mon titre”, “link”:“http://xxxx.fr” },
{ “id”:9, “title”:“Mon titre”, “link”:“http://xxxx.fr” },
{ “id”:10, “title”:“Mon titre”, “link”:“http://xxxx.fr” }
]
}
Je regarde en boucle la video du cours iOS 3 (81 - “Remplir une UITableView avec des données du web”) mais je ne parvient à chercher les données que je souhaite dans ma boucle.
Comment récupérer “title” par exemple? Je ne vois comment imbriquer des clé/valeur dans d’autres clé/valeurs. C’est une histoire de syntaxe je présume.
if let news = response.result.value as? [String:Any] {
print(news["data"]) //ca fonctionne, je récupère le data du json (qui contient tous les articles), mais je ne peux pas aller plus loin dans l'arborescence
for data in news {
print("------> \(data["data"]["title"]))")
}
}
HEEEEEEELP