如何将dispatch_time_t转换为CFAbsoluteTime或struct timespec?

huangapple go评论58阅读模式
英文:

How to convert dispatch_time_t to CFAbsoluteTime or struct timespec?

问题

使用Apple的Grand Central Dispatch(GCD)来创建定时器时,你会看到一个dispatch_time_t 64位整数,它保存了GCD的时间。但是,如何将其值转换为CFAbsoluteTimestruct 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.

huangapple
  • 本文由 发表于 2023年5月17日 22:20:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76273143.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定