Kodeco Forums

Learn To Code iOS Apps With Swift Tutorial 4: Your First App

In this fourth part of this five part series, it’s finally time to make your first iPhone App in Swift!


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1574-learn-to-code-ios-apps-with-swift-tutorial-4-your-first-app

I am having an error in this function:

setupGame() {
seconds = 30
count = 0

timerLabel.text = "Time: \(seconds)"
scoreLabel.text = "Score: \(count)"
timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("subtractTime"), userInfo: nil, repeats: true)

}

The coding is exactly as shown in the solution provided.
error is at Selector(“subtractTime”) …

Can you help?

keeps, I was having that issue also, but this fixed it.

func setupGame() {
    seconds = 30
    count = 0
    
    timerLabel.text = "time: \(seconds)"
    scoreLabel.text = "score: \(count)"
    timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(ViewController.subtractTime), userInfo: nil, repeats: true)
}

i am getting error, i even tried replacing my view controller file with the file you made available for download still the same error persists

Hi there, great tutorial!

I was just wondering if it would be easy to make the timer start counting down on the first button press.

I’ve tried a few ideas floating around on Google but can’t seem to make them work.

Keep up the great work! :+1: