RSDAnswerResultType
public struct RSDAnswerResultType : Codable, Hashable, Equatable
RSDAnswerResultType is a Codable struct that can be used to describe how to encode and decode an RSDAnswerResult.
It carries information about the type of the value and how to encode it. This struct serves a different purpose from
the RSDFormDataType because it only carries information required to store a result and not additional information
about presentation style.
-
Override equality to not include the original formDataType.
Declaration
Swift
public static func == (lhs: RSDAnswerResultType, rhs: RSDAnswerResultType) -> Bool -
Override the hash into to not include the original formDataType.
Declaration
Swift
public func hash(into hasher: inout Hasher) -
The base type of the answer result. This is used to indicate what the type is of the value being stored. The value stored in the
See moreRSDAnswerResultshould be convertable to one of these base types.Declaration
Swift
public enum BaseType : String, Codable, RSDStringEnumSet -
The sequence type of the answer result. This is used to represent a multiple-choice answer array or a key/value dictionary.
See moreDeclaration
Swift
public enum SequenceType : String, Codable, RSDStringEnumSet -
The base type for the answer.
Declaration
Swift
public let baseType: BaseType -
The sequence type (if any) for the answer.
Declaration
Swift
public let sequenceType: SequenceType? -
The original data type of the form input item.
Declaration
Swift
public var formDataType: RSDFormDataType? -
The date format that should be used to encode and decode the answer.
Declaration
Swift
public let dateFormat: String? -
The date formatter locale identifier that should be used to encode and decode the answer. If nil, the default Locale will be set to
en_US_POSIX
.Declaration
Swift
public var dateLocaleIdentifier: String? -
The unit (if any) to store with the answer for localized measurement conversion.
Declaration
Swift
public let unit: String? -
A conveniece property for accessing the formatter used to encode and decode a date.
Declaration
Swift
public var dateFormatter: DateFormatter? { get } -
The sequence separator to use when storing a multiple component answer as a string.
For example, blood pressure might be represented using an array with two fields but is stored as a single string value of
120/90
. In this case,/
would be the separator.Declaration
Swift
public private(set) var sequenceSeparator: String? { get } -
The initializer for the
RSDAnswerResultType.Declaration
Swift
public init(baseType: BaseType, sequenceType: SequenceType? = nil, formDataType: RSDFormDataType? = nil, dateFormat: String? = nil, unit: String? = nil, sequenceSeparator: String? = nil)Parameters
baseTypeThe base type for the answer. Required.
sequenceTypeThe sequence type (if any) for the answer. Default is
nil.dateFormatThe date format that should be used to encode the answer. Default is
nil.unitThe unit (if any) to store with the answer for localized measurement conversion. Default is
nil.sequenceSeparatorThe sequence separator to use when storing a multiple component answer as a string. Default is
nil. -
Static type for a
RSDAnswerResultTypewith aBoolbase type.Declaration
Swift
public static let boolean: RSDAnswerResultType -
Static type for a
RSDAnswerResultTypewith aDatabase type.Declaration
Swift
public static let data: RSDAnswerResultType -
Static type for a
RSDAnswerResultTypewith aDatebase type.Declaration
Swift
public static let date: RSDAnswerResultType -
Static type for a
RSDAnswerResultTypewith aDoubleorDecimalbase type.Declaration
Swift
public static let decimal: RSDAnswerResultType -
Static type for a
RSDAnswerResultTypewith anIntbase type.Declaration
Swift
public static let integer: RSDAnswerResultType -
Static type for a
RSDAnswerResultTypewith aStringbase type.Declaration
Swift
public static let string: RSDAnswerResultType -
Static type for a
RSDAnswerResultTypewith aCodablebase type.Declaration
Swift
public static let codable: RSDAnswerResultType
-
Decode a
RSDJSONValuefrom the given JSON value.Throws
DecodingErrorif the encountered stored value cannot be decoded.Declaration
Swift
public func jsonDecode(from jsonValue: RSDJSONSerializable?, with dataType: RSDFormDataType? = nil) throws -> Any?Parameters
jsonValueThe JSON value (from an array or dictionary) with the answer.
dataTypeThe data type to use to hint at the transform.
Return Value
The decoded value or
nilif the value is not present. -
Decode a
RSDJSONValuefrom the given decoder.Throws
DecodingErrorif the encountered stored value cannot be decoded.Declaration
Swift
public func decodeValue(from decoder: Decoder) throws -> RSDJSONValue?Parameters
decoderThe decoder that holds the value.
Return Value
The decoded value or
nilif the value is not present.
-
Returns a JSON serializable object that is encoded for this answer type from the given value.
- paramenter value: The value to encode.
Declaration
Swift
public func jsonEncode(from value: Any?) throws -> RSDJSONSerializable?Return Value
The JSON serializable object for this encodable.
-
Encode a value to the given encoder.
Throws
EncodingErrorif the value cannot be encoded.Declaration
Swift
public func encode(_ value: Any?, to encoder: Encoder) throwsParameters
valueThe value to encode.
encoderThe encoder to mutate.
View on GitHub
RSDAnswerResultType Structure Reference