TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Igor Matyushkin.
The way to manage time in Swift.
Eternal
folder to your project.or
Eternal
cocoapodNote: For Swift 2.x use Eternal v1.1
. For Swift 3.0 use 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
}
Eternal
is available under the MIT license. See the LICENSE
file for more info.