NSTimer not firing when NSMenu is open in Swift

You just have to add your timer to the main runloop as follow:

Swift 4.2

RunLoop.main.add(timer, forMode: .common)

Swift 3

RunLoop.main.add(alarm, forMode: .commonModes)

Swift 2.x

NSRunLoop.mainRunLoop().addTimer(alarm, forMode: NSRunLoopCommonModes)

Leave a Comment