- iOS 13.0+
- Xcode 12.4+
- Swift 5.5+
Import the framework:
import Thrimer
It is recommended that you set an instance variable for Thrimer:
class ViewController: UIViewController {
var thrimer: Thrimer?
Initialize your property and start automatically, creating a non-repeating timer that runs for 10 seconds.
thrimer = Thrimer(interval: 10.0, repeats: false)
Initialize your property, the following creates a non-repeating timer that runs for 10 seconds and does not auto start.
thrimer = Thrimer(interval: 10.0, repeats: false, autostart: false)
And start the timer when you are ready:
thrimer?.start()
This creates a non-repeating timer with a 10 second duration.
let thrimer = Thrimer(interval: 10.0, repeats: false, autostart: false)
thrimer.start()
Once the timer is running, you can now pause it:
thrimer.pause()
You can check to see if it is paused:
if thrimer.isPaused {
print("Timer is paused")
}
You can check to see how much time is remaining on the timer:
print(thrimer.timeRemaining ?? "Timer is not paused")
Finally, you can resume it:
thrimer.resume()
If you need to stop the timer:
thrimer.stop()
If you find an issue or can think of an improvement, issues and pull requests are always welcome.
For pull requests, please be sure to ensure your work is covered with existing or new unit tests.
Sean McNeil
Thrimer is available under the MIT license. See the LICENSE file for more info.