0
Hello, yesterday I was doing the requisicao as in the code below, and was returning normally. But today when running again (without any change) the code is not returning me, it comes up to this line:
let objetoFilme = try JSONDecoder().decode(ModeloFilme.self, from: data)
and join the catch
import Foundation
import Alamofire
protocol filmesProtocolo: class {
func recuperaFilmes()
}
protocol RespostaAPI {
func success(Modelo: ModeloFilme)
func failure()
}
class FilmeAPI: NSObject, filmesProtocolo {
var delegate: RespostaAPI?
func configura(delegate: RespostaAPI){
self.delegate = delegate
}
// MARK: - GET
func recuperaFilmes() {
Alamofire.request("url", method: .get).responseJSON { (response) in
switch response.result{
case .success:
if let resposta = response.result.value as? Dictionary<String, Any> {
do {
guard let data = response.data else {return}
let objetoFilme = try JSONDecoder().decode(ModeloFilme.self, from: data)
self.delegate?.success(Modelo: objetoFilme)
} catch {
print("Falhou aqui")
}
}
break
case .failure:
print(response.error!)
break
}
}
}
}
Exchange the
print("Falhou aqui")
forprint(error)
, perhaps the value ofdata
have new keys, print it tbm.– rray