I'm working with timer and I've try to make it works in background. On simulator this works fine but on my device (iOS 11) it's very slow: 1 seconde became 5 or 6 secondes...
This is my code for run application in background:
backgroundTaskIdentifier = UIApplication.shared.beginBackgroundTask(
expirationHandler:
{UIApplication.shared.endBackgroundTask(self.backgroundTaskIdentifier!)}
)
Info.plist: Application does not run in background : NO
How can I make it works?
EDIT:
This is my timer code:
timer = Timer.scheduledTimer(timeInterval: 0.01, target: self,
selector:#selector(ViewController.updateTimer), userInfo: nil, repeats: true)
EDIT 2:
func updateTimer () {
var j = 0
for _ in rows {
if (rows[j]["Playing"] as! Bool == true ) {
rows[j]["time"] = (rows[j]["time"] as! Double + 0.01) as AnyObject
// print(rows[j]["time"]) - PRINT OUTPUT HERE
rows[j]["lastTime"] = (rows[j]["lastTime"] as! Double + 0.01) as AnyObject
}
if (rows[j]["lastTime"] as! Double > 60.0) {
min[j] += 1
rows[j]["lastTime"] = 0.00 as AnyObject
}
j += 1
}
}