I'm making a mini pokedex app, and within the view controller, I was hoping to include a description of each pokemon from pokeapi.co, but when I run my code, it remains empty text. Here's the function:
func loadDesc() {
URLSession.shared.dataTask(with: url2!) { (data, response, error) in
guard let data = data else {
return
}
do {
let result2 = try JSONDecoder().decode(PokemonDescResult.self, from: data)
for description in result2.flavor_text_entries {
self.pokeDesc.text = description.flavor_text
}
}
catch let error {
print(error)
}
}.resume()
}
I'm also pretty knew to Swift and stackoverflow, so if you need ant more code to understand, let me know. Thanks!