func RevisarConectividad() -> String
{
var Estado = ""
let Referencia = Database.database().reference(withPath: ".info/connected")
Referencia.observe(.value, with:
{ snapshot in
if snapshot.value as? Bool ?? false
{
Estado = "Conectado"
}
else
{
Estado = "NoConectado"
}
print(Estado)
})
print("Estado:" + " " + Estado)
return Estado
}
I call it like:
let Estado = RevisarConectividad()
But for some reason, it seems Estado never took any of the both string. Anyway, I print "Estado" inside the closure and it is working, it prints its value correctly.