问题
I need some help with this:
func checkUserCredentials() -> Bool{
PFUser.logInWithUsername(userName!, password: Contraseña!)
if (PFUser.currentUser() != nil){
return true
}
return false
}
It says that PFUser.logInWithUsername(userName!, password: Contraseña!) has problems because its not marked with try ... and the error is not handled.
回答1:
func checkUserCredentials() -> Bool{
do {
try PFUser.logInWithUsername(userName!, password: Contraseña!)
} catch{
// deal here with errors
}
return PFUser.currentUser() != nil ? true : false
}
As it is quite basic issue I recommend you reading some tutorials
回答2:
Just replace this
if (PFUser.currentUser() != nil) {
with
if let currentUser = try? PFUser.currentUser() {
来源:https://stackoverflow.com/questions/33039138/try-and-catch-error-with-parse-com