-1

想要比较CMTime并基于我正在执行循环。转换ObjectiveCSwift,我找不到合适的方法CMTIME_COMPARE_INLINE

CMTime oneSecond = CMTimeMake( 1, 1 );
CMTime oneSecondAgo = CMTimeSubtract( timestamp, oneSecond );

while( CMTIME_COMPARE_INLINE( [_previousSecondTimestamps[0] CMTimeValue], <, oneSecondAgo ) ) {
    [_previousSecondTimestamps removeObjectAtIndex:0];
}

有没有人在任何版本中遇到过类似的问题Swift

4

1 回答 1

3

CMTime在 Swift 3 中作为Comparable类型导入,因此,您无需使用CMTIME_COMPARE_INLINE.

假设_previousSecondTimestamps[CMTime](*1) 类型,您可以在 Swift 3 中编写如下内容:

    let oneSecond = CMTime(seconds: 1.0, preferredTimescale: 1)
    let oneSecondAgo = timestamp - oneSecond

    while !_previousSecondTimestamps.isEmpty && _previousSecondTimestamps[0] < oneSecondAgo {
        _previousSecondTimestamps.remove(at: 0)
    }

*1 在 Swift 中,你可以CMTime直接声明一个 Array ,你不需要使用NSMutableArraycontains NSValue

于 2016-12-20T05:11:59.833 回答