what does it mean
This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes ?
i read something about
DispatchQueue.main.async { //code }
i don't understand it quite well
@IBAction func CrearCuenta(_ sender: UIButton) {
guard
let nombreConductorTextt = Nombre_Completo.text, !nombreConductorTextt.isEmpty,
let emailTextt = Correo.text, !emailTextt.isEmpty,
let passwordTextt = Password.text, !passwordTextt.isEmpty,
let confirmarpassTextt = passConfirma.text, !confirmarpassTextt.isEmpty,
let telefonoTextt = Telefono.text, !telefonoTextt.isEmpty,
let telefonoContactoTextt = Telefono_Contacto.text, !telefonoContactoTextt.isEmpty,
let emailContactoTextt = Email_Contacto.text, !emailContactoTextt.isEmpty
else {
displayAlert(title: "Información Faltante", message: "Debes porporcionar los datos solicitados")
return
}
guard passwordTextt == confirmarpassTextt else {
displayAlert(title: "Usuario", message: "Las contraseñas no coinciden")
return
}
var request = URLRequest(url: URL(string: "hehe")!)
request.httpMethod = "POST"
let postParams = [
"Nombre_Completo": nombreConductorTextt,
"Correo": emailTextt,
"Password": passwordTextt,
"Telefono": telefonoTextt,
"Email_Contacto": emailContactoTextt,
"Telefono_Contacto": telefonoContactoTextt,
]
let postString = postParams.map {"\($0.key.urlQueryValueEscaped)=\($0.value.urlQueryValueEscaped)"}
.joined(separator: "&")
request.httpBody = postString.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request) {
data, response, error in
if let error = error {
print("error=\(error)")
self.displayAlert(title: "Error", message: "Trata denuevo")
return
}
print("response = \(response?.description ?? "")")
guard let data = data else {
print("Something wrong: data = nil")
return
}
let responseString = String(data: data, encoding: .utf8)!
print("responseString = \(responseString)")
self.displayAlert(title: "Registro exitoso", message: "¡Usuario creado!")
self.Nombre_Completo.text = ""
self.Correo.text = ""
self.Password.text = ""
self.passConfirma.text = ""
self.Telefono.text = ""
self.Telefono_Contacto.text = ""
self.Email_Contacto.text = ""
}
task.resume()
}
plz any hints?