测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可协议 | MIT |
发布最新发布 | 2017年10月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Igor Matyushkin 维护。
Swift中管理时间的方式。
Eternal
文件夹的内容复制到您项目中。或者
Eternal
cocoa pod注意:对于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
文件。