永久4.0

永久 4.0

测试已测试
语言语言 SwiftSwift
许可协议 MIT
发布最新发布2017年10月
SwiftSwift 版本3.0
SPM支持 SPM

Igor Matyushkin 维护。




永久 4.0

Eternal

摘要

Swift中管理时间的方式。

如何开始

  • Eternal文件夹的内容复制到您项目中。

或者

  • 使用Eternal cocoa pod

需求

  • iOS 9.0及以后版本
  • Xcode 8及以后版本

注意:对于Swift 2.x,请使用Eternal v1.1。对于Swift 3.0,请使用Eternal v3.0

用法

/*
 * Create timer.
 */
let timer1 = ETTimer()


/*
 * Start timer with block.
 * On every call of block you will get number of ticks
 * and time interval which has gone from the start.
 */

timer1.startWithTimeInterval(1.0, repeats: true) { (timer, tickCount, timeIntervalSinceStart) -> Void in
    NSLog("Timer did tick %d times. %.0f seconds has gone from the launch.", tickCount, timeIntervalSinceStart)
}


/*
 * Example of timer which will tick one time only.
 */

timer1.startWithTimeInterval(1.0, repeats: false) { (timer, tickCount, timeIntervalSinceStart) -> Void in
    NSLog("Timer did tick")
}


/*
 * When you don't need timer to continue ticks,
 * call stop() method:
 */

timer1.stop()


/*
 * There's also a shortened form of timer creation:
 */

ETTimer.every(1.0) { (timer, tickCount, timeIntervalSinceStart) -> Void in
    // Do something every second
}


/*
 * Similar method for timer that will perform one time only:
 */

ETTimer.after(1.0) { (timer, tickCount, timeIntervalSinceStart) -> Void in
    // Do something one time
}

许可协议

永久存储软件在MIT许可协议下发布。更多信息请参阅LICENSE文件。