This is Timer module written in Swift
PausableTimer provides two classes.
PausableTimer provide Timer function.
PausableTimer.shared.setDuration(200)
PausableTimer.shared.didStart = {
print("This text will be printed when timer was started.")
}
PausableTimer.shared.didPause = {
print("This text will be printed when timer was paused.")
}
PausableTimer.shared.didResume = {
print("This text will be printed when timer was resumed.")
}
PausableTimer.shared.didStop = { isFinished in
print("This text will be printed when stop() method was called or elapsed duration.")
}
print(PausableTimer.shared.isRunning()) //false
print(PausableTimer.shared.remainingDuration()) //200
PausableTimer.shared.start() //This will invoke didStart closure
print(PausableTimer.shared.isRunning()) //true
//10sec later...
print(PausableTimer.shared.remainingDuration()) //190
PausableTimer.shared.pause() //This will invoke didPause closure
print(PausableTimer.shared.isRunning()) //false
PausableTimer.shared.resume() //This will invoke didResume closure
print(PausableTimer.shared.isRunning()) //true
TimerDurationConverter generate appropriate string from duration.
print(TimerDurationConverter.durationString(30)) //00:30
print(TimerDurationConverter.durationString(1800)) //30:00
print(TimerDurationConverter.durationString(3690)) //01:01:30
- iOS 10.0+
- Xcode 9.0 or above
PausableTimer is now supporting Swift4.
PausableTimer supports only iOS and Carthage.
To integrate PausableTimer into your Xcode project using Carthage, specify it in your Cartfile:
github "nerd0geek1/PausableTimer"
Then, run the following command:
$ carthage update
This software is Open Source under the MIT license, see LICENSE for details.