尝试通过Parse.com捕获错误 [英] Try and catch Error with Parse.com

查看:84
本文介绍了尝试通过Parse.com捕获错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助:

func checkUserCredentials() -> Bool{
      PFUser.logInWithUsername(userName!, password: Contraseña!)
       if (PFUser.currentUser() != nil){
            return true
        }
        return false
   }

它说PFUser.logInWithUsername(userName !,密码:Contraseña!)有问题,因为它没有用try标记,并且错误没有得到处理.

It says that PFUser.logInWithUsername(userName!, password: Contraseña!) has problems because its not marked with try ... and the error is not handled.

推荐答案

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

这篇关于尝试通过Parse.com捕获错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆