【问题标题】:How to get tenths of second, hundredth of second, etc from an NSTimeInterval如何从 NSTimeInterval 获取十分之一秒、百分之一秒等
【发布时间】:2015-11-24 02:09:14
【问题描述】:

如何在 Swift 中从 NSTimeInterval 获取十分之一秒、百分之一秒、毫秒等?

【问题讨论】:

  • 除以 10, 100, 1000
  • 什么? NStimeInterval? NSDate?

标签: swift time milliseconds nstimeinterval seconds


【解决方案1】:

NSTimeInterval 将秒表示为Doubletypealias。您可以通过潜水它的值来获得十分之一、百分之一秒等:

let timeInterval = NSTimeInterval(1.0) // 1 second

let tenth = timeInterval / 10.0 // 0.1
let hundreth = timeInterval / 100.0 // 0.01
let millisecond = timeInterval / 1000.0 // 0.001

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多