Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I keep getting this error in Swift. "Consecutive Declarations On A Line Must Be Separated By ';'"

Tags:

ios

swift

Here is my code, any help is much appreciated thank you! This was written in Xcode in Swift. 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..."
                }
like image 863
LemonTree Avatar asked Oct 01 '14 00:10

LemonTree


1 Answers

Looks like you had an extra space between View and Controller in the class name and also a lot of missing closing parentheses.

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
            } 
        }
    }
}
like image 81
Austen Chongpison Avatar answered Sep 21 '22 23:09

Austen Chongpison