OGeek|极客世界-中国程序员成长平台

标题: ios - 获取 CFAbsoluteTime 和 NSDate 之间的时间差 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:53
标题: ios - 获取 CFAbsoluteTime 和 NSDate 之间的时间差

我有一个 CFAbsoluteTime,我需要获取当前时间之间的时间差并将其作为 CFAbsoluteTime 返回。有没有办法做到这一点,不包括我作为 NSDate 进行所有转换?



Best Answer-推荐答案


时间差由 CFTimeInterval 表示,而不是 CFAbsoluteTime,但无论如何它们实际上都是 double 的类型别名。所以得到 NSDateCFAbsoluteTime 并减去:

CFTimeInterval difference = someAbsoluteTime - myDate.timeIntervalSinceReferenceDate;

关于ios - 获取 CFAbsoluteTime 和 NSDate 之间的时间差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26025426/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4