Re: Adding 30 minutes to an NSDate
Re: Adding 30 minutes to an NSDate
- Subject: Re: Adding 30 minutes to an NSDate
- From: Nicko van Someren <email@hidden>
- Date: Wed, 20 Jul 2005 11:06:41 +0100
On 20 Jul 2005, at 10:57, Andy Lee wrote:
On Jul 20, 2005, at 4:54 AM, Nicko van Someren wrote:
On 20 Jul 2005, at 8:24, j o a r wrote:
Do you really have to care about all that, if all you want is to
chime every hour? Why not simply set a timer to fire in 60
minutes, regardless of which calendar day that happens to be?
You don't want to just fire after 60 mins from when your last
timer function was triggered. NSTimers can fire late, especially
if the machine is asleep at the time that the timer was supposed
to fire, so firing at Now+60mins will tend to drift; if you want
the timer to go off on the hour where possible this will be bad.
I assumed Joar meant the NSTimer should be set to be auto-
repeating, using the "interval:" argument in the various NSTimer
creation/init methods. According to the docs, this causes the
scheduling to do the right thing (at least for this purpose) if a
timer happens to fire late.
Now that I re-read Joar's post, I can see how it might be
interpreted differently.
Oh, I read "set a timer to fire in 60 minutes" as meaning setting the
timer again inside the triggered selector. As we all seem to agree,
using a repeating timer seems to be the answer.
Anyway, see <file://localhost/Developer/ADC Reference Library/
documentation/CoreFoundation/Reference/CFRunLoopTimerRef/
index.html>. I just filed a documentation request to have this
information duplicated in the NSTimer docs.
Sounds like a good plan.
Cheers,
Nicko
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden