Is this the most efficient way to do this? Any suggestions on some thing I might have missed or can do better?
func checkPasscodeMatch(){
println(self.passCodetext1.text)
println(self.passCodetext2.text)
// check if pass codes match
if self.passCodetext1.text == self.passCodetext2.text {
//check if pass code 1 is blank
if self.passCodetext1.text == "" {
let alertView = UIAlertController(title: "ALERT!!", message: "Pass code can not be blank", preferredStyle: UIAlertControllerStyle.Alert)
alertView.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alertView, animated: true, completion: nil)
} else {
defaults.setObject(passCodetext1.text, forKey: "passCode")//store pass code
dispatch_async(dispatch_get_main_queue()) {
self.performSegueWithIdentifier("setupTouchID", sender: self)
}
}
} else {
let alertView = UIAlertController(title: "ALERT!!", message: "Pass Codes do not match", preferredStyle: UIAlertControllerStyle.Alert)
alertView.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alertView, animated: true, completion: nil)
passCodetext1.text = ""
passCodetext2.text = ""
passCodetext2.resignFirstResponder()
println("Pass codes do not match.")
}
}