我有一种创建帐户的方法:
func createAccount (completion: @escaping (_ succes: Bool, _ message : String)->()) {
Auth.auth().createUser(withEmail: createMail(), password: createPassword()) { (result, error) in
if let _eror = error {
//something bad happning
print(_eror.localizedDescription )
if let errorCode = AuthErrorCode(rawValue: _eror._code) {
if(errorCode.rawValue == 17007) {
print("acount exist")
createAccount(completion: (Bool, String) -> ()
} else {
//call itself and try it again
}
}
} else {
//user registered successfully
print("user registered")
return completion(true, "");
}
}
}
当软件使用已经存在的电子邮件创建帐户时,我会遇到错误(请参阅else
语句-//call itself and try it again
(。
需要发生的事情是,该功能需要再次调用自己以通过不同的电子邮件尝试。
我试图将createAccount(completion: (Bool, String) -> ()
放在else
情况下,但这无效。
在其他情况下如何再次调用createAccount()
函数?
您需要再次传递相同的参数
createAccount(completion:completion)