开发者

Show app running time in iPhone

I would like to write a counter that shows how many 开发者_如何学Cseconds an app has be running for. (textView) and the counter should be cumulative and starts from where it left off. Im new to iphone sdk.


you are going to have to do these things:

get the time when the app starts in applicationDidFinishLaunching: in your application delegate

check if you have an old time using NSUserDefaults

have a thread that updates the ui (your textView display, may i suggest using a label instead) with the ever increasing time using NSThread or NSTimer - i recommend NSThread. you will also need to perform your updates on your ui thread as updating your ui from a background thread can just get lost in the post.

store the end time in applicationWillTerminate: in your application delegate using NSUserDefaults

lots of googling ahead of you, have fun!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜