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.

On Jul 26, 2010, at 4:56 AM, Matt Gough wrote:

> I need to calculate (with an accuracy of 0.1 of a second) a real-time time 
> interval. This interval should:
> 
> 1. Not be affected by whether the system has been put to sleep and woken up 
> while timing. (i.e If I start the timer then sleep the Mac for an hour and 
> wake it up again, my interval should be just over 60 minutes)
> 2. Not be affected by changes to the wall clock. (i.e If I start the timer, 
> leave it for an hour and then set the wall clock back to the start time, my 
> interval should be just over 60 minutes and not zero)
> 
> Up to now, I have been using mach_absolute_time (which satisfies condition 
> 2), but had not noticed that it could not satisfy condition 1. There are 
> several other higher level versions (i.e Uptime, Microseconds), but they all 
> seem to call down to mach_absolute_time.
> 
> Obviously all the wall-clock based based (NSDate date], 
> CFAbsoluteTimeGetCurrent) are also out of bounds due to condition 2.
> 
> Have I missed something obvious, or is this just not doable?
> 
> Thanks
> 
> Matt Gough_______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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/3tothe4th%40comcast.net
> 
> This email sent to 3tothe...@comcast.net

Charlie Dickman
3tothe...@comcast.net



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to