我曾经在 Objective-C 中使用以下内容:
double currentTime = CFAbsoluteTimeGetCurrent();
// self.startTime is called before, like
// self.startTime = CFAbsoluteTimeGetCurrent();
double elapsedTime = currentTime - self.startTime;
// Convert the double to milliseconds
unsigned long long milliSecs = (unsigned long long)(elapsedTime * 1000);
在我目前的快速代码中:
let currentTime: Double = CFAbsoluteTimeGetCurrent()
let elapsedTime: Double = currentTime - startTime
let milliSecs: CUnsignedLongLong = elapsedTime * 1000
但是,我得到一个错误,即 adouble
无法转换为 a CUnsignedLongLong
,这是有道理的。有没有办法像在 Objective-C 中一样投射它?有没有解决的办法?