TheBestClockAlarmSetting
@objc(TheBestClockAlarmSetting)
class TheBestClockAlarmSetting : NSObject, NSCoding
-
The number of minutes we snooze for.
Declaration
Swift
let snoozeTimeInMinutes: Int
-
The length of time an alarm will blare, in minutes.
Declaration
Swift
let alarmTimeInMinutes: Int
-
SAVED IN STATE: The time (HHMM) for the alarm.
Declaration
Swift
var alarmTime: Int
-
SAVED IN STATE: True, for vibrate.
Declaration
Swift
var isVibrateOn: Bool
-
SAVED IN STATE: The sound mode.
Declaration
Swift
var selectedSoundMode: AlarmPrefsMode
-
SAVED IN STATE: If the sound mode is sounds, the index of the stored sound.
Declaration
Swift
var selectedSoundIndex: Int
-
SAVED IN STATE: If the sound mode is music, the resource URL of the selected song.
Declaration
Swift
var selectedSongURL: String
-
SAVED IN STATE: True, if the alarm is active.
Declaration
Swift
var isActive: Bool { get set }
-
EPHEMERAL: The time a “snooze” started.
Declaration
Swift
var lastSnoozeTime: Date!
-
EPHEMERAL: The time that an alarm was deactivated, so it doesn’t keep going off if we reactivate it.
Declaration
Swift
var deactivateTime: Date!
-
EPHEMERAL: The time to be used as the start of the alarm range. This can be “bumped.” If nil, then the set alarm time will be used to calculate the range.
Declaration
Swift
var alarmResetTime: Date!
-
Declaration
Swift
var snoozing: Bool { get set }
Return Value
True, if the alarm is currently “snoozing.”
-
This handles “deferring” an alarm. That prevents it from going off immediately when turned back on.
Basic rule: It should ALWAYS be deferred when activating from the front panel, or when starting/bringing forward the app. It can be reset from the Alarm Editor Screen.
Declaration
Swift
var deferred: Bool { get set }
Return Value
True, if the alarm has been “deferred,” and should not go off again.
-
Declaration
Swift
var currentAlarmTime: Date! { get }
Return Value
The alarm set, for today, with the possibility of being deferred.
-
Declaration
Swift
var todaysAlarmTime: Date! { get }
Return Value
The alarm set, for today.
-
This just resets the three main “ephemeral” states.
Declaration
Swift
func clearState()
-
Declaration
Swift
func alarmEngaged(withResetAdded: Bool = false) -> Int
Parameters
withResetAdded
An optional Bool (default is false), that, if true, will include a cascading reset time.
Return Value
1 if the alarm will be going off now. 0, if the alarm will not go off soon, or -1 if the alarm will go off within the alarm time window from now.
-
Declaration
Swift
var isAlarming: Bool { get }
Return Value
True, if the alarm should be blaring right now.
-
This is the standard NSCoding saver.
Declaration
Swift
func encode(with aCoder: NSCoder)
Parameters
with
The NSCoder object that will receive the “serialized” state.
-
Standard empty init.
Declaration
Swift
override init()
-
NSCoding initializer.
Declaration
Swift
required init?(coder aDecoder: NSCoder)
Parameters
coder
The coder that we will get our state from.