无法将类型((User ?, _)->()'的值转换为预期的参数类型'AuthDataResultCallback?'

时间:2018-07-30 19:13:48

标签: ios swift firebase firebase-authentication

我收到以下错误:

  

无法将类型((User ?, _)->()'的值转换为预期的参数类型'AuthDataResultCallback?' (aka'可选<(可选,可选<错误>)->()>')

此代码的第七行:

func handleRegister() {
    guard let email = emailTextField.text, let password = passwordTextField.text, let name = nameTextField.text else {
        print("Form is not valid")
        return
    }

    Auth.auth().createUser(withEmail: email, password: password, completion: { (user, error) in

        if error != nil {
            print(error!)
            return
        }

        guard let uid = user?.uid else {
            return
        }

        //successfully authenticated user
        let imageName = UUID().uuidString
        let storageRef = Storage.storage().reference().child("profile_images").child("\(imageName).jpg")

        if let profileImage = self.profileImageView.image, let uploadData = UIImageJPEGRepresentation(profileImage, 0.1) {

//            if let uploadData = UIImagePNGRepresentation(self.profileImageView.image!) {

            storageRef.putData(uploadData, metadata: nil, completion: { (metadata, error) in

                if error != nil {
                    print(error!)
                    return
                }

                if let profileImageUrl = metadata?.downloadURL()?.absoluteString {

                    let values = ["name": name, "email": email, "profileImageUrl": profileImageUrl]

                    self.registerUserIntoDatabaseWithUID(uid, values: values as [String : AnyObject])
                }
            })
        }
    })
}

0 个答案:

没有答案