hey i am trying to call a function every 1 second but i keep getting the following error:
terminating with uncaught exception of type NSException
this is the code i have and i get the error when i press the button.
var startButton : UIButton!
var theTime = 0;
var countDownText = "hello"
var countDownTimer = NSTimer
startButton = UIButton(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height))
startButton.center = CGPointMake(view.frame.size.width / 2, view.frame.size.height/3)
startButton.setTitle("\(countDownText)", forState: UIControlState.Normal)
startButton.setTitleColor(UIColor.darkGrayColor(), forState: UIControlState.Normal)
startButton.addTarget(self, action: Selector("countDownFunc"), forControlEvents: UIControlEvents.TouchUpInside)
self.view?.addSubview(startButton)
func countDownFunc() {
countDownTimer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("countDownFunc2:"), userInfo: nil, repeats: true)
}
func countDownFunc2(){
theTime++
countDownText = "HELLOOOOOOOOO"
}
print(theTime)
i have no clue how to fix this error :( any help would be greatly appreciated!!