Ios 得到一个;“需要申报”;错误,但不';我不知道该怎么做(Xcode)
刚刚添加了一个警报,最后得到一个“需要声明”错误,我已经添加了“;”系统建议但仍然不工作,代码如下:Ios 得到一个;“需要申报”;错误,但不';我不知道该怎么做(Xcode),ios,swift,Ios,Swift,刚刚添加了一个警报,最后得到一个“需要声明”错误,我已经添加了“;”系统建议但仍然不工作,代码如下: class SignUpViewController: UIViewController { @IBAction func BackToFirstPageButton(sender: AnyObject) { performSegueWithIdentifier("BackToLogInPage", sender: self) } @IBOutlet var Usern
class SignUpViewController: UIViewController {
@IBAction func BackToFirstPageButton(sender: AnyObject) {
performSegueWithIdentifier("BackToLogInPage", sender: self)
}
@IBOutlet var UsernameTextField: UITextField!
@IBOutlet var PasswordTextField: UITextField!
@IBOutlet var EmailTextField: UITextField!
@IBAction func SignUpButton(sender: AnyObject) {
if UsernameTextField.text == "" || PasswordTextField.text == "" || EmailTextField.text == "" {
let SignUpAlert = UIAlertController (title: "Error in form", message: "Please fill in the blanks", preferredStyle: UIAlertControllerStyle.Alert)
SignUpAlert.addAction((UIAlertAction(title: "Dismiss", style: .Default, handler: { (action) -> Void in
self.dismissViewControllerAnimated(true, completion: nil)
})))
self.presentViewController(SignUpAlert, animated: true, completion: nil)
}
func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
};
最后一个括号和冒号是我得到声明错误的地方。请帮忙。第一次在这里发帖,所以如果我遗漏了什么,请告诉我。谢谢 在swift中,您不需要“;”like objective-c看起来您在SignUpButton方法中的if语句中缺少了一个结束括号 尝试:
此方法中缺少右大括号
@IBAction func SignUpButton(sender: AnyObject) {
...
}
您可以通过将光标悬停在行号和代码之间的小列上(突出显示当前范围)或在单击方法声明行左侧显示的小三角形时折叠方法来检查是否正确。您需要添加最后一个结束括号“}”,您可以亚历山德罗·基亚罗托说去掉“;” 对,但方法的大括号对后的分号不会导致编译器错误。请在末尾添加另一个“}”
@IBAction func SignUpButton(sender: AnyObject) {
...
}