Mode
There are two timer modes: oneShot
means the timer works only once; period
means the timer works periodically.
enum Mode
There are two timer modes: oneShot
means the timer works only once; period
means the timer works periodically.
enum Mode
import SwiftIO
The SwiftIO library allows you to access and control the hardware in an easy way.
final class Timer
The Timer class can measure the time passed. If the time limit is reached, it can execute a specified task.
case oneShot
case period
init(mode: Mode = .period, period: Int = 1000)
Initializes a timer.
let obj: UnsafeMutableRawPointer
func getRemaining() -> UInt32
Computes the (approximate) time remaining before a running timer next expires. If the timer is not running, it returns zero.
func getStatus() -> UInt32
Gets the timer’s status which indicates how many times the timer has expired since it was last read. It will reset the status to zero.
func setInterrupt(start: Bool = true, _ callback: @escaping () -> Void)
Executes a designated task at a scheduled time interval.
func start(mode: Mode? = nil, period: Int? = nil)
Starts the timer and reset its status to zero.
func stop()
Stops the timer.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.