RSDAnswerResultType
public struct RSDAnswerResultType : Codable
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.
-
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 -
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 -
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 let 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? -
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? -
Static type for a
RSDAnswerResultTypewith aBoolbase type.Declaration
Swift
public static let boolean = RSDAnswerResultType(baseType: .boolean) -
Static type for a
RSDAnswerResultTypewith aDatabase type.Declaration
Swift
public static let data = RSDAnswerResultType(baseType: .data) -
Static type for a
RSDAnswerResultTypewith aDatebase type.Declaration
Swift
public static let date = RSDAnswerResultType(baseType: .date) -
Static type for a
RSDAnswerResultTypewith aDoubleorDecimalbase type.Declaration
Swift
public static let decimal = RSDAnswerResultType(baseType: .decimal) -
Static type for a
RSDAnswerResultTypewith anIntbase type.Declaration
Swift
public static let integer = RSDAnswerResultType(baseType: .integer) -
Static type for a
RSDAnswerResultTypewith aStringbase type.Declaration
Swift
public static let string = RSDAnswerResultType(baseType: .string) -
Static type for a
RSDAnswerResultTypewith aTimeIntervalbase type.Declaration
Swift
public static let timeInterval = RSDAnswerResultType(baseType: .timeInterval) -
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.
-
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. -
Undocumented
Declaration
Swift
public func decodeDate(from string: String) -> Date?
-
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.
-
Undocumented
Declaration
Swift
public var description: String -
Declaration
Swift
public var hashValue: Int -
Declaration
Swift
public static func ==(lhs: RSDAnswerResultType, rhs: RSDAnswerResultType) -> Bool
View on GitHub
RSDAnswerResultType Structure Reference