Firebase创建用户swift不起作用

时间:2016-04-28 06:10:35

标签: swift firebase firebase-authentication

下面我输入的是错误显示"无法覆盖类型'()的值 - >虚空'预期参数类型'(NSERROR!) - > VOID)'!

关于这行代码:会出现什么问题?

FIREBASE_REF.createUser(email, password: password, withCompletionBlock: {(error,authData) -> Void in

@IBAction func creatAccountAction(sender: AnyObject) {
        let email = self.emailTextField.text
        let password = self.passwordTextField.text

        if email != "" && password != ""
        {
            FIREBASE_REF.createUser(email, password: password, withCompletionBlock: {(error,authData) -> Void in

            if error != nil {

                FIREBASE_REF.authUser(email, password: password, withCompletionBlock: { (error, authData) -> Void in

                    if error == nil {

                        NSUserDefaults.standardUserDefaults().setValue(authData.uid, forKey: "uid")
                    }
                    else {
                        print (error)
                    }
                })
            }
            else {
                print (error)
            }

            }

            )}

        else

2 个答案:

答案 0 :(得分:2)

试试这个:

FIREBASE_REF.createUser(email, password: password, withCompletionBlock: {(error) -> Void in

这个块可能只有一个参数

答案 1 :(得分:0)

创建用户有两个选项,一个只创建它并在失败时返回错误(withCompletionBlock),另一个也返回authData(withValueCompletionBlock):那是你想要的那个。

1000