开发者

iPhone- Dynamically update NSDate for clock?

开发者 https://www.devze.com 2023-01-08 02:27 出处:网络
I\'ve made a clock, and 开发者_如何学CI\'m trying to update it so it displays, well, the time. When I initiate the NSDate it is an instance of the exact current time, for the time it was initiated. So

I've made a clock, and 开发者_如何学CI'm trying to update it so it displays, well, the time. When I initiate the NSDate it is an instance of the exact current time, for the time it was initiated. So what I have going on here is pinging the updateTime function with an NSTimer to update the clock every 3 seconds.

It seems that there should be a way to do this better? I'm afraid I'm using more resources then necessary by doing this method, and while performance isn't really an issue for a clock, I'd like to get better at my resource management.


Don't be afraid of NSTimer. A timer that fires once a second (or even less in your case) hardly uses any resources. It's the way to do this.

0

精彩评论

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