Skip to content

Timer Start Up

Alina P edited this page Nov 30, 2024 · 5 revisions

Tutaj, aby utrzymać się w tym samym miejscu (…), trzeba biec, ile sił

Timer Start Up

Overview

You can start the timer anytime and from anywhere in your code. There are several methods available to help you with that.

Important

Timer can be run backwards - use any to value that is greater than from.

Available Methods

  • func start(from startTime: MTime = .zero, to endTime: MTime = .max) throws

    • Starts the timer using the specified initial values.
    • Allows to set-up time in a user friendly way
  • func start(from startTime: MTime = .zero, to endTime: MTime = .max) throws

    • Starts the timer using the specified initial values.
  • func start() throws

    • Starts up going infinity timer

Usage

Start with using MTime property

func startTimer() throws {
   let timeFrom = MTime(timeInterval: 1)
   let timeTo = MTime(minutes: 2, seconds: 14, milliseconds: 5)
        
   try MTimer(.id).start(from: timeFrom, to: timeTo)
}

Start with using TimeInterval property

func startTimer() throws {
   try MTimer(.id).start(from: .zero, to: 10)
}

Start infinity timer

func startTimer() throws {
   try MTimer(.id).start()
}

Start down going timer

func startTimer() throws {
   try MTimer(.id).start(from: 10, to: .zero)
}

See also