简体   繁体   English

我一直在Swift中遇到这个错误。 “一条线上的连续声明必须分开';'”

[英]I keep getting this error in Swift. “Consecutive Declarations On A Line Must Be Separated By ';'”

Here is my code, any help is much appreciated thank you! 这是我的代码,非常感谢任何帮助谢谢! This was written in Xcode in Swift. 这是用Swift中的Xcode编写的。 I keep getting the error that states "Consecutive Declarations On A Line Must Be Separated By ';'" 我一直收到错误,指出“一条线上的连续声明必须分开';'”

     import UIKit

class View Controller: UIViewController {
@IBOutlet var outputLabel: UILabel! = UILabel()

var currentCount : Int = 0

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


@IBAction func addOneButton(sender: UIButton) {

    currentCount = currentCount + 1
    if(currentCount <= 1) {
        outputLabel.text = "The button has been clicked 1 time!"
    outputLabel.textColor = UIColor.purpleColor()
    }
    else {
    outputLabel.text = "The button has been clicked \(currentCount) number of times."
    outputLabel.textColor = UIColor.redColor()


        var Hello: UILabel! {
            if(currentCount >= 5) {
                outputLabel.text = "Don't Forget To Give A GOOD Rating! :D"
            outputLabel.textColor = UIColor.orangeColor()
            }
            else {
                outputLabel.text = "Nothing To See Here..."
                }

Looks like you had an extra space between View and Controller in the class name and also a lot of missing closing parentheses. 看起来你在类名中的View和Controller之间有一个额外的空间,还有很多缺少的右括号。

Try this: 试试这个:

import UIKit

class ViewController: UIViewController {
    @IBOutlet var outputLabel: UILabel! = UILabel()

    var currentCount : Int = 0

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    @IBAction func addOneButton(sender: UIButton) {

        currentCount = currentCount + 1
        if(currentCount <= 1) {
            outputLabel.text = "The button has been clicked 1 time!"
            outputLabel.textColor = UIColor.purpleColor()
        }
        else {
            outputLabel.text = "The button has been clicked \(currentCount) number of times."
            outputLabel.textColor = UIColor.redColor()

            var Hello: UILabel! {
                if(currentCount >= 5) {
                    outputLabel.text = "Don't Forget To Give A GOOD Rating! :D"
                    outputLabel.textColor = UIColor.orangeColor()
                }
                else {
                    outputLabel.text = "Nothing To See Here..."
                }
                return outputLabel
            } 
        }
    }
}
    var Hello: UILabel! {

This line looks wrong. 这条线看起来不对。 Remove it. 去掉它。

Edit 编辑

There are also } missing at the end. 最后也有}失踪。
Correctly indenting your code will help spotting such errors a lot! 正确缩进代码将有助于发现这些错误!

Edit 2 编辑2

Oh and I guess you mean class ViewController instead of class View Controller . 哦,我猜你的意思是class ViewController而不是class View Controller

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xcode Swift 3连续声明必须用;分隔; 建立错误 - Xcode Swift 3 Consecutive declarations on line must be separated by ; build error 一行中的连续声明必须用'; - Consecutive declarations on a line must be separated by '; 行上的连续声明必须以“;”分隔 - Consecutive Declarations on Line Must be Separated By ";" Swift 错误:一行上的连续语句必须用';'分隔 - Swift Error: Consecutive statements on a line must be separated by ';' 一行中的连续声明必须用';'分隔关于createstripeuser - Consecutive declarations on a line must be separated by ';' with regards to createstripeuser 关于一行连续声明的Swift错误 - Swift error about consecutive declarations on a line 在Swift中使用JSONDecoder时,我不断收到“没有与键相关的值”错误。 有人可以解释这里出了什么问题吗? - I keep getting the “No value associated with key” error when using the JSONDecoder in Swift. Can someone please explain what is going wrong here? guard let - 一行上的连续陈述必须用&#39;;&#39;分隔 3 - guard let - Consecutive statements on a line must be separated by ';' 3 SKAction.customActionWithDuration行上的连续语句必须用&#39;;&#39;分隔 - SKAction.customActionWithDuration Consecutive statements on a line must be separated by ';' 如何在SceneKit中编写新的着色器文件:一行上的连续语句必须用;分隔? - How to write in a new shader file in SceneKit: consecutive statements on a line must be separated by ;?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM