CODING PROBLEM

i'm trying to make a countdown timer but i keep getting an error saying "expected declaration"

Here is my coding:


import UIKit

class View2: UIViewController{


var timerCount = 0

var timerRunning = false

var timer = NSTimer()


@IBOutlet weak var timerlabel: UILabel!


func Counting(){

timerCount += 1

timerlabel.text = "\(timerCount)"

}




@IBAction func startButton(sender: UIButton) {

if timerRunning == false{

timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("Cou nting"), userInfo: nil, repeats: true)

timerRunning = true

}

}


@IBAction func stopButton(sender: UIButton) {


if timerRunning == true{

timer .invalidate()

timerRunning = false

}

}


func resetButton(sender: UIButton) {

timerCount = 0

timerlabel.text = "0"

}


override func viewDidLoad() {

super.viewDidLoad()

/

}

override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

/

}

}

I recommend you'd give a better title for your post. Including the error message is one way, if it's not too long.

And you also show what version of Xcode you are using, just adding something like "Xcode 6.4 on OS X 10.10.4" would be useful in many cases.


I assume this sort of lines:

        /

may be modified by the article editor's copying feature and your original code would be something like this:

        // Do any additional setup after loading the view, typically from a nib.

as in the code template generated by Xcode. You'd better post-edit your code after pasting it.


So, if I try to get the message "Expected declaration", I need to write some other codes, other than your code shown above.


Are you sure your source file does not contain any other codes?

i dont understand please could you explain in more detail, and i dont have any other codes.

I mean I cannot reproduce the same result "expected declaration" with your code above, both in Xcode 7 beta 5 and Xcode 6.4 .


Create a freshly new project.

Replace the whole content of ViewController.swift file by the code in your post above.

Build it and see what messages does the compiler generates.

okay thankyou very much

CODING PROBLEM
 
 
Q