Why can’t I display the value in the print?

Asked

Viewed 30 times

0

I want to display in the console the value of the name variable that appears is "(lldb)", why?

@IBAction func botaoAcesse(_ sender: Any) {

    let cpf = self.campoCPF.text
    let senha = self.campoSenha.text

    let param = ["cpf": cpf, "senha": senha, "method": "app-get-login", "plataforma":"ios"]
    var _: HTTPHeaders = ["Content-Type": "application/json"]
    let url = "http://easypasse.com.br/gestao/wsLogin.php"

    Alamofire.request(url, method:.post, parameters:param,encoding: JSONEncoding.default).responseJSON { response in
        switch response.result {
        case .success:
            print(response)
            if let JSON = response.result.value as? [String: Any] {
                let registro =  JSON["registro"] as? String
                let usuario = JSON["usuario"] as? String
                let nome = JSON["nome"] as? String
                print(nome!)

            }

        case .failure(let error):
            print(0,"Error")
        }
    }
}

inserir a descrição da imagem aqui

1 answer

0

Dear friend,

First start by adjusting your return Json as it doesn’t seem right and so it might not be entering your if Let.

To help you I suggest validating your json on the site : https://jsonformatter.curiousconcept.com/

  • But this is a json object, inside another.

  • And someone else did it.

  • JSON is correct! Veja https://stackoverflow.com/questions/51270389/why-cant-i-show-data-in-print .

Browser other questions tagged

You are not signed in. Login or sign up in order to post.