Contents

init(countingDownIn:showsHours:maxFieldCount:maxPrecision:)

Creates a timer format style that counts down within the interval you provide.

Declaration

init(countingDownIn interval: Range<Date>, showsHours: Bool = true, maxFieldCount: Int = 3, maxPrecision: Duration = .seconds(1))

Parameters

  • interval:

    The time interval during which the timer counts down.

  • showsHours:

    If true, hours appear as a separate element when the remaining time is at least one hour. If false, minutes accumulate beyond 60.

  • maxFieldCount:

    The maximum number of fields shown at once. With the default of 3, output includes hours, minutes, and seconds. With 2, it shows hours and minutes once the time reaches hours.

  • maxPrecision:

    The smallest time interval between display updates. Defaults to 1 second.

Discussion

The timer displays the remaining time, starting from the total interval duration and decreasing to zero.