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 RSDAnswerResult should be convertable to one of these base types.

    See more

    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 more

    Declaration

    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 RSDAnswerResultType with a Bool base type.

    Declaration

    Swift

    public static let boolean = RSDAnswerResultType(baseType: .boolean)
  • Static type for a RSDAnswerResultType with a Data base type.

    Declaration

    Swift

    public static let data = RSDAnswerResultType(baseType: .data)
  • Static type for a RSDAnswerResultType with a Date base type.

    Declaration

    Swift

    public static let date = RSDAnswerResultType(baseType: .date)
  • Static type for a RSDAnswerResultType with a Double or Decimal base type.

    Declaration

    Swift

    public static let decimal = RSDAnswerResultType(baseType: .decimal)
  • Static type for a RSDAnswerResultType with an Int base type.

    Declaration

    Swift

    public static let integer = RSDAnswerResultType(baseType: .integer)
  • Static type for a RSDAnswerResultType with a String base type.

    Declaration

    Swift

    public static let string = RSDAnswerResultType(baseType: .string)
  • Static type for a RSDAnswerResultType with a TimeInterval base 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

    baseType

    The base type for the answer. Required.

    sequenceType

    The sequence type (if any) for the answer. Default is nil.

    dateFormat

    The date format that should be used to encode the answer. Default is nil.

    unit

    The unit (if any) to store with the answer for localized measurement conversion. Default is nil.

    sequenceSeparator

    The sequence separator to use when storing a multiple component answer as a string. Default is nil.

  • Decode a RSDJSONValue from the given decoder.

    Throws

    DecodingError if the encountered stored value cannot be decoded.

    Declaration

    Swift

    public func decodeValue(from decoder:Decoder) throws -> RSDJSONValue?

    Parameters

    decoder

    The decoder that holds the value.

    Return Value

    The decoded value or nil if the value is not present.

  • Undocumented

    Declaration

    Swift

    public func decodeDate(from string: String) -> Date?
  • Encode a value to the given encoder.

    Throws

    EncodingError if the value cannot be encoded.

    Declaration

    Swift

    public func encode(_ value: Any?, to encoder: Encoder) throws

    Parameters

    value

    The value to encode.

    encoder

    The 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