Re: Displaying time
Re: Displaying time
- Subject: Re: Displaying time
- From: Ron Fleckner <email@hidden>
- Date: Sat, 23 Aug 2008 00:01:42 +1000
On 22/08/2008, at 11:28 PM, Graham Cox wrote:
On 22 Aug 2008, at 10:55 pm, Ron Fleckner wrote:
Sorry, my question was very badly put. I've already apologised to
two other answerers. I should have said: Is there a better way -
other than using an NSTimer - to update the clock? That is, how
does the system clock do it?
I think now that this is not strictly a Cocoa question.
Using a timer isn't too bad. Running at two updates per second
should be acceptable since you're sampling at twice the highest
"event" frequency. You might want to go a bit faster and maybe at
a slightly odd multiple of one second to make sure you don't end up
with a constant half-second lag.
The timer should compare the previous second with the current
second and only update the display if it's changed. That way your
timer isn't wasting cycles redrawing the same thing every time, but
only when it changes.
hth,
Graham
OK, thanks Graham. I'll stick with the timer. Your suggestion of
increasing the fire rate of the timer works well. I've set it to
fire at 0.3 seconds and the display is almost exactly the same as the
menu bar clock.
Thanks again,
Ron
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden