1

below I just typed is error showing "Cannot cover value of type '(,) -> Void' to expected argument type '(NSERROR!) -> Void!)'

on this line of code: what would be wrong?

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 Answers 2

1

Try this:

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

This block has probably only one parameter

Sign up to request clarification or add additional context in comments.

Comments

0

There are two options for creating a user, one just creates it and returns an error if it fails (withCompletionBlock), the other also returns the authData (withValueCompletionBlock): that's the one you want.

myRootRef.createUser(email, password: pw, withValueCompletionBlock: { error, result in

            if error != nil {
                print("error creating user")
            } else {
                let uid = result["uid"] as! String
                NSUserDefaults.standardUserDefaults().setValue(uid, forKey: "uid")
                //pass the parameters to another function to auth the user
                self.authUserWithAuthData( email, password: pw ) 
            }

        })

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.