How do I add a timer using Swift?

Viewed 1402

I have come across a lot of questions similar to this, but many were for older versions of Xcode, or simply did not work. I'm using Xcode Version 8.3.2 (8E2002) and Swift coding language. I don't know much about coding, but am young and eager to learn! I'm creating a clicker game that will give you money per second that you are on the game itself. So if you idle for 2 minutes, it would give you $120 ($1per second @120 sec). In addition to this, you also can earn money from clicking the main object. Here is my coding so far:

import UIKit

class ViewController: UIViewController {

var score = 0
var add = 1

func addpersec() {

    score += 1
}
//func used to add to the score based timer. Aka, adding 1 per second



@IBOutlet weak var scorecount: UILabel!


@IBAction func clicks(_ sender: Any) {
    score += 1
    scorecount.text = "Honey: \(score)"
}

@IBOutlet weak var Bees: UITableView!

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


}
2 Answers
Related