In my app I have a NSTimer
, and a selector - (void)TimerCount
. I also have a integer int CountNum
, and every 0.01 second, it increases
You can use NSuserdefaults to save your countNum, whenever user will quit the app it will be saved. Just call this into APPDELEGATE function - (void)applicationWillTerminate:(UIApplication *)application {
NSUserDefault *defaults = [NSUser Defaults standardUserDefaults];
[defaults setInteger: countNum forKeys:@"ANY_KEY_HERE"];
[defaults synchronise];
the above code will save your countNum, but you have to save it when user will terminate or go into background.
And When User will come into foreground you can call to retrive your countNum
NSUserDefault *defaults = [NSUser Defaults standardUserDefaults];
yourCountNum = [default getIntegerForKeys: @"ANY_KEY_HERE"];