changing label value in background?
i am changing the label's value through timer(having interval of 1 second) by incrementing the count of an integer variable... I close the app....label starts incremented its value from where it was stopped...so app resumes 开发者_开发知识库it self from where it was stopped...but is there any way to take the labels value to the time for which it is closed i.e. if I close the app at the labels value 23...and close the app for 10 seconds...so when i open the app the labels starts incrementing itself from 33?? Thanks...
You could use a NSDate
to store the initial time (i.e., when the timer was started) and then subtracting the NSDate
from current time every second and setting the label to the difference.
Since it is time based, you can record the time at which the app is closed. When the app is opened again, you can get the time lapsed and based on the size of the time interval increase the count appropriately.
精彩评论