Enter Description here
Enter Description here
var user = PFUser()
user.username = "myUsername"
user.password = "myPassword"
user.email = "email@example.com"
user.signUpInBackgroundWithBlock {
(succeeded: Bool, error: NSError?) -> Void in
if let error = error {
let errorString = error.userInfo["error"] as? NSString
// Show the errorString somewhere and let the user try again.
} else {
// Hooray! Let them use the app now.
}
}
Enter Description here
PFUser.logInWithUsername(inBackground: "email@emaill.com", password:"password1234") {
(user: PFUser?, error: Error?) -> Void in
if user != nil {
// login successful - transition to next screen
}
else {
// The login failed. Check error to see why.
let alertController = UIAlertController(title: "Could not login!", message: error?.localizedDescription , preferredStyle: UIAlertControllerStyle.alert)
alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.default,handler: nil))
self.present(alertController, animated: true, completion: nil)
}
}