RSDActiveUIStepObject
open class RSDActiveUIStepObject : RSDUIStepObject, RSDActiveUIStep
RSDActiveUIStepObject extends the RSDUIStepObject to include a duration and commands. This is used for the
case where an RSDUIStep has an action such as start walking
or stop walking
; the step may also implement
the RSDActiveUIStep protocol to allow for spoken instruction.
-
The duration of time to run the step. If
0, then this value is ignored.Declaration
Swift
public var duration: TimeInterval = 0 -
The set of commands to apply to this active step. These indicate actions to fire at the beginning and end of the step such as playing a sound as well as whether or not to automatically start and finish the step.
Seealso
RSDActiveUIStepCommand.stringMappingfor a list of the coding strings included in this framework.Declaration
Swift
public var commands: RSDActiveUIStepCommand = .defaultCommands -
Whether or not the step uses audio, such as the speech synthesizer, that should play whether or not the user has the mute switch turned on. Default =
false.Declaration
Swift
public var requiresBackgroundAudio: Bool = false
-
A mapping of the localized text that represents an instructional voice prompt to the time marker for speaking the instruction.
The mapping is
Codableusing eitherTimeIntervalvalues as the keys or by using theSpokenInstructionKeysas special keys into the mapping dictionary.example:
// Example JSON dictionary that includes a spoken instruction map. let json = """ { "identifier": "foo", "type": "active", "title": "Hello World!", "text": "Some text.", "duration": 30, "requiresBackgroundAudio": true, "commands": ["playSoundOnStart", "vibrateOnFinish"], "spokenInstructions" : { "start": "Start moving", "10": "Keep going", "halfway": "Halfway there", "countdown": "5", "end": "Stop moving"} } """.data(using: .utf8)! // our data in native (JSON) format // The decoded mapping. self.spokenInstructions = [ 0.0 : "Start moving", 10.0 : "Keep going", 15.0 : "Halfway there", 25.0 : "five", 26.0 : "four", 27.0 : "three", 28.0 : "two", 29.0 : "one", Double.infinity : "Stop moving"]
Declaration
Swift
public var spokenInstructions: [TimeInterval : String]? -
The
SpokenInstructionKeysare specialized markers for the timing of when to speak the spoken instruction. These include keys that can be transformed into a time interval using the duration of the step to indicate thehalfwaypoint.See moreSeealso
spokenInstructionsDeclaration
Swift
public enum SpokenInstructionKeys : String, CodingKey -
Localized text that represents an instructional voice prompt. Instructional speech begins when the step passes the time indicated by the given time. If
timeIntervalis greater than or equal todurationor is equal toDouble.infinity, then the spoken instruction returned should be for when the step is finished.Declaration
Swift
open func spokenInstruction(at timeInterval: TimeInterval) -> String?Parameters
timeIntervalThe time interval at which to speak the instruction.
Return Value
The localized instruction to speak or
nilif there isn’t an instruction.
Coding (spoken instructions requires special handling and Codable auto-synthesis does not work with subclassing)
-
Default initializer.
Declaration
Swift
public override init(identifier: String, type: RSDStepType? = nil)Parameters
identifierA short string that uniquely identifies the step.
typeThe type of the step. Default =
RSDStepType.active -
Initialize from a
Decoder.example:
// Example JSON dictionary that includes a duration, commands, and spoken instruction mapping. let json = """ { "identifier": "foo", "type": "active", "title": "Hello World!", "text": "Some text.", "duration": 30, "commands": ["playSoundOnStart", "vibrateOnFinish"], "spokenInstructions" : { "start": "Start moving", "10": "Keep going", "halfway": "Halfway there", "countdown": "5", "end": "Stop moving"} } """.data(using: .utf8)! // our data in native (JSON) formatThrows
DecodingErrorDeclaration
Swift
public required init(from decoder: Decoder) throwsParameters
decoderThe decoder to use to decode this instance.
-
A step to merge with this step that carries replacement info. This step will look at the replacement info in the generic step and replace properties on self as appropriate.
For an
RSDActiveUIStepObject, thedurationproperty can be replaced.Declaration
Swift
open override func replace(from step: RSDGenericStep) throws
View on GitHub
RSDActiveUIStepObject Class Reference