In below code, continue block is executing only for failure cases but not for success cases.
QMServicesManager().authService.signUpAndLogin(with: user).continue({ (users: BFTask!) -> Any? in
if users.isFaulted || (users.error != nil) {
let alert = UIAlertController(title: "Error!", message: "Some error occurred on server", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
else if users.isCancelled {
let alert = UIAlertController(title: "Error!", message: "User registration is not completed", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
else if users.result != nil {
let alert = UIAlertController(title: "Done!", message: "User (users.result!.fullName) registration is successful", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
return nil
})
In below code, continue block is executing only for failure cases but not for success cases.
QMServicesManager().authService.signUpAndLogin(with: user).continue({ (users: BFTask!) -> Any? in
if users.isFaulted || (users.error != nil) {
let alert = UIAlertController(title: "Error!", message: "Some error occurred on server", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
else if users.isCancelled {
let alert = UIAlertController(title: "Error!", message: "User registration is not completed", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
else if users.result != nil {
let alert = UIAlertController(title: "Done!", message: "User (users.result!.fullName) registration is successful", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
return nil
})