For my application, it requires the user to login. If the user login is invalid, I need to let the user know that. So I was wondering how to bring up an UIAlertView if the login parameters are invalid. It automatically lets me know in the terminal if its valid or invalid. But I need to know how to create an AlertView so the user knows they entered their information successfully or unsuccessfully.
CODE
IBAction func loginTapped(sender: AnyObject) {
let username = usernameField.text
let password = passwordField.text
if username.isEmpty || password.isEmpty {
var emptyFieldsError:UIAlertView = UIAlertView(title: "Please try again", message: "Please fill in all the fields we can get you logged in to your account.", delegate: self, cancelButtonTitle: "Try again")
emptyFieldsError.show()
}
PFUser.logInWithUsernameInBackground(username, password:password) {
(user: PFUser?, error: NSError?) -> Void in
if user != nil {
println("Sucessful")
} else {
println("Invalid login")
}
}
}