【发布时间】:2016-03-22 16:51:35
【问题描述】:
我正在尝试为以下示例找到解决方案。我已经创建了一个用户注册页面,我检查了密码重置问题与实际密码不匹配(工作正常),但我想要做的是将输入的密码和密码重置问题转换为小写并检查没有匹配。我更愿意即时执行此操作,而不是将密码放入 var。
这样做的原因是为了确保密码重置问题与实际密码不同,无论特定字符的大小写。
if (passWord.text) == (resetQuestion.text) {
let alertController = UIAlertController(title: "PASSWORD SECURITY ISSUE", message:
"password reset question must not match actual password!", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
return
}
if String.lowercaseString.rangeOfString(passWord.text) == String.lowercaseString.rangeOfString(resetQuestion.text) {
let alertController = UIAlertController(title: "PASSWORD SECURITY ISSUE", message:
"password reset question must not match actual password!", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
return
}
任何指点或帮助将不胜感激。
【问题讨论】: