I am using an nstimer to count down but it seems to be counting down in 4s instead of 1s here is my code can you help me fixs this:
func failsafeon() {
if failsafeper == "off" {
if currentamountofwrong == 0 {
currentamountofwrong = currentamountofwrong + 1
count1 = 20
timer1 = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("countdown"), userInfo: nil, repeats: true)
}
if currentamountofwrong == 1 {
currentamountofwrong = currentamountofwrong + 1
count1 = 45
timer1 = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("countdown"), userInfo: nil, repeats: true)
}
if currentamountofwrong == 2 {
currentamountofwrong = currentamountofwrong + 1
count1 = 90
timer1 = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("countdown"), userInfo: nil, repeats: true)
}
if currentamountofwrong > 2 {
currentamountofwrong = currentamountofwrong + 1
count1 = 90
timer1 = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("countdown"), userInfo: nil, repeats: true)
}
a.enabled = false
b.enabled = false
c.enabled = false
d.enabled = false
a.alpha = 3
b.alpha = 3
c.alpha = 3
d.alpha = 3
} else {
print("failsafeoff")
}
}
func countdown() {
print("count down start1")
faillabel()
--count1
faillabel()
if count1 == 0 || count1 < 1 {
timer1.invalidate()
count1 = 0
faillbl.text = "FailSafe: OFF"
a.enabled = true
b.enabled = true
c.enabled = true
d.enabled = true
a.backgroundColor = UIColor.whiteColor()
b.backgroundColor = UIColor.whiteColor()
c.backgroundColor = UIColor.whiteColor()
d.backgroundColor = UIColor.whiteColor()
a.alpha = 10
b.alpha = 10
c.alpha = 10
d.alpha = 10
}
}
func faillabel() {
faillbl.text = "FailSafe: \(count1) Remaning"
print("count down start2")
}