我试图在重置密码按钮中向文本字段添加一些错误。
在这里:
@IBAction func SendButton(sender: AnyObject) {
if EmailTF.text == ""
{
let alert = UIAlertController(title: "Oops!", message:"Make sure to fill in the required text field", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in })
self.presentViewController(alert, animated: true){}
}
else
{
ref.resetPasswordForUser(EmailTF.text){ (error) -> Void in
if error != nil
{
if let errorCode = FAuthenticationError(rawValue: error.code) {
switch (errorCode) {
case .UserDoesNotExist:
print("User Doesn't Exist")
let alert = UIAlertController(title: "Oops!", message:"This user doesn't exist", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in })
self.presentViewController(alert, animated: true){}
case .NetworkError:
print("Network Error")
let alert = UIAlertController(title: "Oops!", message:"Network error, check your connection", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in })
self.presentViewController(alert, animated: true){}
case .InvalidEmail:
print("invalid email")
let alert = UIAlertController(title: "Oops!", message:"invalid email", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in })
self.presentViewController(alert, animated: true){}
default:
print("Unknown Error")
let alert = UIAlertController(title: "Oops!", message:"Unknown Error", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in })
self.presentViewController(alert, animated: true){}
}//switch
}//if
}// if
else
{
print("Success")
if let Email = self.EmailTF.text{
let alert = UIAlertController(title: "Sucess!", message:"Password reset sent to your email address ( \(Email) )" , preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { _ in })
self.presentViewController(alert, animated: true){}
}
}//else
}
}//1st else
}//send button
每当我尝试在文本字段中输入无效的电子邮件时,就会出现错误电子邮件!
InvalidEmail案例永远不会有效!
invalidEmail错误是否与resetpassword函数无关? 为什么会这样? 怎么了?