As long as the NSTimer firing interval is sufficiently small the NSTimer can be 
used. If the run loop is stalled for any "significant: time _all_ timers will 
be inaccurate to some degree. The NSTimer works fine for animation and , e.g., 
alarm timers and they are consistent across platforms such as Mac Pros, iMacs, 
iPhones, etc.

On Jul 26, 2010, at 12:12 PM, Kyle Sluder wrote:

> On Jul 26, 2010, at 8:32 AM, Charlie Dickman <[email protected]> wrote:
> 
>> Try using an NSTimer with a repeating timeout interval of, say, .001 (or 
>> anything smaller than your required accuracy), and countdown your time delta 
>> by the same amount each time the NSTimer fires and when you get to zero 
>> you'll have what you need.
> 
> NSTimer is not suitable for timekeeping of any significant resolution. 
> NSTimer works by comparing the current time at the top of the runloop with 
> the last time the timer was fired. Obviously, this is highly susceptible to 
> anything that prevents the runloop from running at at least the timer 
> interval—which on a modern multitasking operating system is quite likely.
> 
> mach_absolute_time is certainly the way to go. The best advice I've seen out 
> there is to listen for sleep/wake notifications from IOKit and record the 
> system time there to figure out how much time has elapsed between the two.
> 
> 
> --Kyle Sluder

Charlie Dickman
[email protected]



_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to