Thrimer
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
Version 3.0
- iOS 11.0+
- Xcode 10.2+
- Swift 5.0+
Installation
Thrimer is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Thrimer"
Instructions
Basic setup
Import the framework:
import Thrimer
It is recommended that you set an instance variable for Thrimer:
class ViewController: UIViewController {
var thrimer: Thrimer?
Express setup
Initialize your property, delegate and start automatically with optional value, a non-repeating timer that runs for 10 seconds.
thrimer = Thrimer(interval: 10.0, delegate: self, repeats: false)
Standard timer
Initialize your property, the following creates a non-repeating timer that runs for 10 seconds.
thrimer = Thrimer(interval: 10.0, repeats: false)
Next, set the delegate:
thrimer?.delegate = self
And start the timer when you are ready:
thrimer?.start()
Delegate
To receive updates when the timer completes, you must comform to the ThrimerDelegate:
extension ViewController: ThrimerDelegate {
func thrimerEvent(thrimer: Thrimer) {
// Event triggered
}
}
Pause timer
This creates a non-repeating timer with a 10 second duration.
let thrimer = Thrimer(interval: 10.0, repeats: false)
thrimer.delegate = self
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()
Changelog
Changelog | See the changes introduced in each version.
Author
seanmcneil, [email protected]
License
Thrimer is available under the MIT license. See the LICENSE file for more info.