-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Description
Hello!
I want to make a function that starts the timer unless there is a bool true in params (e.g. animateStatusIcon(stop: true)) - in that case I want to stop the timer. Does anyone have an idea what's going on here?
The timer starts but no matter what I do it wont stop.
func animateStatusIcon(stop: Bool? = nil){
let icon = NSImage(named: "statusIcon")
let iconActive = NSImage(named: "statusIconActive")
let timer = Timer.every(0.4.seconds) {
self.statusItem.image = icon
Timer.after(0.2.seconds) {
self.statusItem.image = iconActive
}
}
if(stop == true){
print(stop!)
print("should stop now")
timer.invalidate()
} else {
print(stop)
print("start")
timer.start()
}
}Metadata
Metadata
Assignees
Labels
No labels