Re: Synchronize timer with internal clock
Re: Synchronize timer with internal clock
- Subject: Re: Synchronize timer with internal clock
- From: John Timmer <email@hidden>
- Date: Fri, 14 Mar 2003 13:13:08 -0500
If you don't care much about user interactivity for a little while, or can
put the start of the timer into a thread, you can do the following:
NSCalendarDate *now = [NSCalendarDate calendarDate];
Sleep (60 - [now secondOfMinute ]);
Then setup your timer.
The alternative is to set up a single instance timer to trigger in 60 - [now
secondOfMinute] seconds. In the method it calls invalidate it, then set up
a second timer to start firing every 60 seconds.
Cheers,
John
>
Hi all,
>
>
is there an easy way to synchronize a NSTimer with the internal clock?
>
I've a NSTimer object that fires every 60 seconds but independent from
>
the program start time I would like to have the timer fired every minute
>
in sync with the system clock.
>
>
--
>
>
regards
>
Frank Fenn - Bright Light Software
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.