英文:
How to convert dispatch_time_t to CFAbsoluteTime or struct timespec?
问题
使用Apple的Grand Central Dispatch(GCD)来创建定时器时,你会看到一个dispatch_time_t
64位整数,它保存了GCD的时间。但是,如何将其值转换为CFAbsoluteTime
或struct timespec
呢?
英文:
While using Apple's grand central dispatch (GCD) for a timer one can see dispatch_time_t
64-bit integer that holds the time for GCD.
How do you convert its value to CFAbsoluteTime
or struct timespec
though?
答案1
得分: 1
The dispatch_time_t
is an opaque type. It is defined as:
> 一个相对抽象的时间表示;其中零表示“现在”,DISPATCH_TIME_FOREVER
表示“无限”,中间的每个值都是不透明的编码。
I would not advise trying to convert it to another type. I would suggest going back to where you created this dispatch_time_t
object, and creating your other type there.
英文:
The dispatch_time_t
is an opaque type. It is defined as:
> A somewhat abstract representation of time; where zero means “now” and DISPATCH_TIME_FOREVER
means “infinity” and every value in between is an opaque encoding.
I would not advise trying to convert it to another type. I would suggest going back to where you created this dispatch_time_t
object, and creating your other type there.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论