I have a function in a SpriteKit Game that adds a "life" to the user every 5 minutes
startTimer = NSTimer.scheduledTimerWithTimeInterval(300, target: self, selector: #selector(GameScene.addLife), userInfo: nil, repeats: true)
But when the user closes the app this code is killed and there is no way to calculate the amount of life the users has to get when they open back the app.
I wondering how can I count the amount of time since the user closed the app so that I can calculate the amount of life to give.
I was thinking about using NSUserDefaults to store the time right before they closed the app and when they reopen calculate the amount of time from that but the problem is the user can change their time and thus get extra life as a "hack".
Does anyone know how to solve this?