I am working on a macOS App using SwiftUI. My task is to trigger an event every one second on a Mac App using Swift even if the app is in background but unfortunately, I noticed that the second gap was between the triggering block of Timer. I have showed the logs and the code below
here it is my code
let timer = Timer.scheduledTimer(timeInterval: 10, repeats: true, block : {
counter += 1
})
RunLoop.main.add(timer, forMode: .common)
//Second code block which I tried
Timer.scheduledTimer(intervaltime : 1, repeats: true, block: {
timer in
print("date is \(getDate())")
}
here, you can see the seconds gap