获取“声明是必需的”错误,但不知道该怎么做(Xcode)

时间:2015-12-16 10:18:54

标签: ios swift

刚刚在警报中添加并在最后收到“需要声明”错误,我已添加到“;”系统建议但仍然不起作用,代码如下:

([TeamA],[TeamB],[Win],[date])

('KKR','HYD','KKR',1), 
('KKR','MUM','MUM',2), 
('RCB','HYD','HYD',3), 
('DEL','PUB','PUB',4), 
('RR','PUB','RR',4), 
('RR','DEL','RR',5),
('RCB','CSK','CSK',6),
('RR','CSK','RR',7),
('CSK','MUM','MUM',7),
('MUM','DEL','MUM',8),
('HYD','PUNE','PUNE',9),
('PUB','DEL','DEL',9),
('KKR','DEL','KKR',10),
('KKR','RCB','KKR',10)

最后一个括号和冒号是我收到声明错误的地方。请帮忙。第一次在这里张贴所以请告诉我,如果我错过任何东西。谢谢!

4 个答案:

答案 0 :(得分:0)

看起来你在SignUpButton方法内的if语句上错过了一个结束括号

尝试:

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.
  }

};

答案 1 :(得分:0)

此方法中缺少右括号

video { loop: true; autoplay: true; }

您可以将光标悬停在行号和代码之间的小列上 - 这会突出显示当前作用域 - 或者在单击方法声明行左侧显示的小显示三角形时折叠方法

答案 2 :(得分:0)

您需要添加最后一个结束括号'}'你可以像Alessandro Chiarotto那样删除&#39 ;;'

答案 3 :(得分:-1)

快点你不需要';'像objective-c