【发布时间】:2017-12-11 22:07:15
【问题描述】:
我的 Swift 代码有问题 当出现错误时,方法 verifyInput 应该返回 false 但它总是返回 true 无论什么 + 当有错误时它打印“错误”但它只是返回 true
请帮忙
@IBAction func register(_ sender: UIButton) {
let check = verifyInput(email :email.text! ,password: password.text!)
if(check==true){
self.performSegue(withIdentifier: "goToAmazon", sender: nil)
} else if(check==false) {
self.message.text = "Sorry! there's an error"
}
}
func verifyInput(email: String, password: String) -> Bool {
var check = true
Auth.auth().createUser(withEmail: email, password: password) { (user, error) in
if error != nil {
print("error")
check = false
} else if(error==nil){
check = true
print("registered!")
}
}
return check
}
【问题讨论】:
-
对异步API调用做一些研究。
-
阅读本文可能会帮助您了解更多stackoverflow.com/questions/748175/…
标签: ios swift firebase firebase-authentication