RSDChoiceObject
public struct RSDChoiceObject<T> : RSDChoice, RSDComparable, RSDEmbeddedIconVendor, Codable where T : Decodable, T : Encodable
RSDChoiceObject
is a concrete implementation of RSDChoice
that can be used to
track a multiple choice, single choice, or multiple component input field where each
choice in the input field maps to a specific value.
-
A JSON encodable object to return as the value when this choice is selected.
Declaration
Swift
public var answerValue: Codable? { get }
-
Localized text string to display for the choice.
Declaration
Swift
public let text: String?
-
Additional detail text.
Declaration
Swift
public let detail: String?
-
For a multiple choice option, is this choice mutually exclusive? For example,
none of the above
.Declaration
Swift
public let isExclusive: Bool
-
Whether or not this choice has an image associated with it that should be returned by the fetch icon method.
Declaration
Swift
public var hasIcon: Bool { get }
-
The optional
RSDImageWrapper
with the pointer to the image.Declaration
Swift
public let icon: RSDImageWrapper?
-
Expected answer for the rule. In this case, it is the
value
associated with this choice.Declaration
Swift
public var matchingAnswer: Any? { get }
-
Default initializer.
Throws
RSDValidationError.invalidImageName
if theiconName
does not map to an image.Declaration
Swift
public init(value: Value?, text: String? = nil, iconName: String? = nil, detail: String? = nil, isExclusive: Bool = false) throws
Parameters
value
A JSON encodable object to return as the value when this choice is selected.
text
Localized text string to display for the choice.
iconName
The name of the icon associated with this choice.
detail
Additional detail text.
isExclusive
For a multiple choice option, is this choice mutually exclusive?
-
Initialize from a
Decoder
. This decoding method will first look to see if the decoder contains a dictionary in which case the coding keys will be decoded from that dictionary. Otherwise, the decoder will decode a singleString
value and set that value as both thevalue
property and thetext
property.Seealso
Throws
DecodingError
Declaration
Swift
public init(from decoder: Decoder) throws
Parameters
decoder
The decoder to use to decode this instance.
-
Encode the result to the given encoder. This will encode the choice as a dictionary.
Throws
EncodingError
Declaration
Swift
public func encode(to encoder: Encoder) throws
Parameters
encoder
The encoder to use to encode this instance.