Firebase完成块的Swift错误消息

时间:2017-02-26 04:45:29

标签: swift firebase

我从这段代码中收到错误。有没有人能解决这个问题?

enter image description here

1 个答案:

答案 0 :(得分:3)

将其更改为:

    FIRAuth.auth()?.signInAnonymously(completion: { (anonymousUser, error) in

        if error == nil{
            print("UserId : \(anonymousUser?.uid)")
        }else{
            print(error?.localizedDescription)
        }

    })

注意:您可以将if语句更改为:

    FIRAuth.auth()?.signInAnonymously(completion: { (anonymousUser, error) in

        if let err = error{
            print(err.localizedDescription)
            return
        }

        print("UserId : \(anonymousUser?.uid)")

    })

为了保存其他内容并使代码更具可读性。