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
Try this:
FIREBASE_REF.createUser(email, password: password, withCompletionBlock: {(error) -> Void in
This block has probably only one parameter
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 )
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.