How can I know if there's a specific string in an array? I want to do something like this:
if (getUsuarios().containsString(usuarioView.text!) == false) {
print("hola")
alerta("Ups, vas a tener que cambiar algo", texto2: "Ese usuario ya existe", alertaNum: "refreshAlert6")
usuarioView.text = ""
}
getUsuarios
is this:
func getUsuarios() -> String {
var usuariosDataBase = [String]()
Alamofire.request(.GET, url)
.responseJSON { response in
print(response)
do {
let json = try NSJSONSerialization.JSONObjectWithData(response.data!, options: .AllowFragments)
if let blogs = json as? [[String: AnyObject]] {
for blog in blogs {
if let usuario = blog["usuario"] as? String {
usuariosDataBase.append(usuario)
}
}
}
} catch {
print("error serializing JSON: \(error)")
}
print(usuariosDataBase)
}
return "\(usuariosDataBase)"
}