xcode 我收到连接到@IBAction func createaccountButton 的错误消息“表达式列表中的预期')'”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38579623/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:04:50  来源:igfitidea点击:

im getting error message "expected ')' in expression list" connected to @IBAction func createaccountButton

swiftxcodeibaction

提问by alex powers

    @IBAction func createaccountButton(sender: AnyObject) { !Expected ')' in expression list
    FIRAuth.auth()?.createUserWithEmail(emailField.text!, password: passwordField.text!, completion: { (user, error) in
        if error == nil {
            print("User Created")

    if (FIRAuth.auth()?.currentUser) != nil
    {
        self.myaccountButton.alpha = 1.0
    }
    else
    {
        self.myaccountButton.alpha = 0.0
        self.welcomeLabel.text = ""
                }
            }
        }
    )}
}

}

}

i cant figure out where to put ) in said expression please help ive tried everything

我不知道把 ) 放在所说的表达式中,请帮助我尝试了所有方法

回答by Frederick Jacob Ladebauche

For those who are having this problem it is because somewhere in your code you are missing a closed parenthesis ). Check the line where you are having the issue or the line before. It is because there is an open parenthesis ( for the argument but no closed parenthesis ) to close it. Make sure your closed parenthesis match the open parenthesis for the argument.

对于那些遇到此问题的人来说,这是因为在您的代码中的某处缺少一个右括号)。检查出现问题的线路或之前的线路。这是因为有一个左括号(用于参数但没有右括号)来关闭它。确保您的右括号与参数的左括号匹配。

For this specific code it's because you have an open parenthesis with no closed parenthesis to close the argument:

对于此特定代码,这是因为您有一个左括号而没有右括号来关闭参数:

(emailField.text!, password: passwordField.text!, completion: { (user, error) in 

You are missing a closed parenthesis above.

您缺少上面的一个右括号。

You also have a closed parenthesis at the bottom for some reason.

出于某种原因,底部还有一个右括号。

        self.welcomeLabel.text = ""
                }
            }
        }
    )} //right here is an obscure closed parenthesis
}

回答by Willjay

Missing ')' just after your password field!

缺少“)”就在您的密码字段之后!

FIRAuth.auth()?.createUserWithEmail(email!, password: password!) { (user, error) in
  if let error = error {
    print(error.localizedDescription)
    return
  }

  print("User Created")

  if let currentUser = FIRAuth.auth()?.currentUser {
     self.myaccountButton.alpha = 1.0
  } else {
     self.myaccountButton.alpha = 0.0
     self.welcomeLabel.text = ""
  }
}

with completion, this works fine with me.

完成后,这对我来说很好用。

 FIRAuth.auth()?.createUserWithEmail(email!, password: password!, completion: { (user, error) in
    if let error = error {
        print(error.localizedDescription)
        return
    }
    print("User Created")

    if let currentUser = FIRAuth.auth()?.currentUser {
         self.myaccountButton.alpha = 1.0
     } else {
         self.myaccountButton.alpha = 0.0
         self.welcomeLabel.text = ""
     }
})