开发者

How to compare two times in milliseconds precision?

I have a subtitle text file that works with standart srt format 00:00:00,000 Hour, minutes, seconds, milliseconds.

I want to create a timer to update the subtitle screen and check the current time to know what subtitle show on screen.

Which is the best to开发者_JAVA技巧 use? NSTimeInterval, NSDate? I think the best is to convert all to times to milliseconds number and compare. But NSTimeInterval works with seconds, not milliseconds.

Some clue?

Marcos


NSTimeInterval is likely what you want. NSTimeInterval is in units of seconds, but has a fractional portion which can represent sub-millisecond values (it's typedef'ed to a double). Thus a value of 2.5 represents 2 seconds + 500ms.

In fact, NSTimer uses NSTimeInterval

+ (NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds
                                invocation:(NSInvocation*)invocation
                                   repeats:(BOOL)repeats;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜