TimerModel
class TimerModel : Equatable
extension TimerModel: Sequence
extension TimerModel: CustomDebugStringConvertible
This contains an entire model of the timer app.
The model consists of groups, which consist of timers. Each timer is a “wrapped” TimerEngine
instance.
This is a class, so it can be referenced.
-
Equatable Conformance
Declaration
Swift
static func == (lhs: TimerModel, rhs: TimerModel) -> Bool
Parameters
lhs
The left-hand side of the comparison.
rhs
The right-hand side of the comparison.
Return Value
True, if the two models are the same.
-
The groups that aggregate timers.
Declaration
Swift
private var _groups: [TimerGroup]
-
The number of groups in this model.
Declaration
Swift
var count: Int { get }
-
True, if there are no timer groups.
Declaration
Swift
var isEmpty: Bool { get }
-
All of the timer wrappers, in one simple array.
Declaration
Swift
var allTimers: [Timer] { get }
-
this exports the current timer state, or allows you to recreate the group, based on a stored state.
Declaration
Swift
var asArray: [[[String : any Hashable]]] { get set }
-
The first timer group
Declaration
Swift
var first: TimerGroup? { get }
-
The last timer group
Declaration
Swift
var last: TimerGroup? { get }
-
The last timer group
Declaration
Swift
var selectedTimer: Timer? { get }
-
subscript access to the groups.
Declaration
Swift
subscript(inIndex: Int) -> TimerGroup { get }
Parameters
inIndex
The 0-based index of the group.
-
subscript access to individual timers.
Declaration
Swift
subscript(indexPath inIndexPath: IndexPath) -> Timer { get }
Parameters
inIndexPath
The index path to the timer.
-
Test if the index path is valid for the model.
Declaration
Swift
func isValid(indexPath inIndexPath: IndexPath) -> Bool
Parameters
inIndexPath
The index path to be tested.
Return Value
True, if the index path is valid for the model.
-
This tests, to see if a timer can be created at, or moved into, the index path.
Declaration
Swift
func canInsertTimer(at inIndexPath: IndexPath, from inFrom: IndexPath? = nil) -> Bool
Parameters
inIndexPath
The indexpath we are testing.
inFrom
Optional. If provided, then it is the source path of the item (for moving within a full groaup).
-
Accessor for an individual timer, within the model.
Declaration
Swift
func getTimer(at inFrom: IndexPath) -> Timer?
Parameters
inFrom
The indexpath to the timer. This must represent a valid, existing timer.
Return Value
The timer instance, or nil, if the indexPath was not valid.
-
This will deselect all the timers in the model, with the possible exception of the given timer.
Declaration
Swift
func deselectAllTimers(except inTimerPath: IndexPath? = nil)
Parameters
inTimerPath
If this is set to a valid index path in the model, that timer will not have its selection state modified (either selected, or not selected). Optional. If not given, all timers are deselected.
-
This will select the timer given (deselects all others).
Declaration
Swift
func selectTimer(_ inTimerPath: IndexPath)
Parameters
inTimerPath
Must be valid within the model. The timer to select.
-
This creates a new, uninitialized timer instance, at the given index path anywhere in the model.
Declaration
Swift
@discardableResult func createNewTimer(at inTo: IndexPath) -> Timer
Parameters
inTo
The index path of the new timer. It can include one beyond the end (appending a new timer, or even a new section, with a new timer).
Return Value
The new timer instance (can be ignored).
-
This creates a new, uninitialized timer instance, at the end of the indexed section
Declaration
Swift
@discardableResult func createNewTimerAtEndOf(group inSection: Int) -> Timer
Parameters
inSection
The 0-based section index.
Return Value
The new timer instance. Can be ignored.
-
This removes a timer from anywhere in the model.
Declaration
Swift
@discardableResult func removeTimer(from inFrom: IndexPath) -> Timer
Parameters
inFrom
The index path to the timer to be removed.
Return Value
The deleted timer (can be ignored).
-
This moves a timer from one part of the model, to another.
Declaration
Swift
@discardableResult func moveTimer(from inFrom: IndexPath, to inTo: IndexPath) -> Timer
Parameters
inFrom
The place the timer originates.
inTo
The destination. This can include one beyond the end (appending).
Return Value
The moved timer (can be ignored).
-
Declaration
Swift
struct TimerModelIterator : IteratorProtocol
-
This is an alias for our iterator.
Declaration
Swift
typealias Iterator = TimerModelIterator
-
Creates a new, primed iterator.
Declaration
Swift
func makeIterator() -> TimerModelIterator
-
Emits a formatted string, describing the model.
Declaration
Swift
var debugDescription: String { get }