RSDNumberRangeObject
public struct RSDNumberRangeObject : RSDNumberRange, RSDRangeWithFormatter, Codable
RSDNumberRangeObject
extends the properties of an RSDInputField
for a decimal
or integer
data type.
-
The minimum allowed number. When the value of this property is
nil
, there is no minimum.Declaration
Swift
public let minimumValue: Decimal?
-
The maximum allowed number. When the value of this property is
nil
, there is no maximum.Declaration
Swift
public let maximumValue: Decimal?
-
A step interval to be used for a slider or picker.
Declaration
Swift
public let stepInterval: Decimal?
-
A unit label associated with this property. The unit should not be localized. Instead, this value is used to determine the unit for measurements converted to the unit expected by the researcher.
For example, if a measurement of distance is displayed and/or returned by the user in feet, but the researcher expects the returned value in meters then the unit here would be
m
and the formatter would be aLengthFormatter
that uses the current locale with aunitStyle
of.long
.Declaration
Swift
public let unit: String?
-
Formatter
that is appropriate to the data type. Ifnil
, the format will be determined by the UI. This is the formatter used to display a previously entered answer to the user or to convert an answer entered in a text field into the appropriate value type.Note
Currently, theCodable
protocol only supports instantiating aNumberFormatter
with amaximumDigits
key that contains the number of decimal places to display.Declaration
Swift
public var formatter: Formatter?
-
Default initializer for a
Decimal
range. This is used to initialize the range for aDecimal
type.Declaration
Swift
public init(minimumDecimal: Decimal?, maximumDecimal: Decimal?, stepInterval: Decimal? = nil, unit: String? = nil, formatter: Formatter? = nil)
Parameters
minimumDecimal
The minimum allowed number.
maximumDecimal
The maximum allowed number.
stepInterval
A step interval to be used for a slider or picker. Default =
nil
.unit
A unit label associated with this property. Default =
nil
.formatter
NumberFormatter
that is appropriate to the data type. Default =nil
. -
Default initializer for an
Int
range. This is used to initialize the range for anInt
type.Declaration
Swift
public init(minimumInt: Int?, maximumInt: Int?, stepInterval: Int? = nil, unit: String? = nil, formatter: Formatter? = nil)
Parameters
minimumInt
The minimum allowed number.
maximumInt
The maximum allowed number.
stepInterval
A step interval to be used for a slider or picker. Default =
nil
.unit
A unit label associated with this property. Default =
nil
.formatter
NumberFormatter
that is appropriate to the data type. Default =nil
. -
Default initializer for an
Double
range. This is used to initialize the range for aDouble
type.Declaration
Swift
public init(minimumDouble: Double?, maximumDouble: Double?, stepInterval: Double? = nil, unit: String? = nil, formatter: Formatter? = nil)
Parameters
minimumDouble
The minimum allowed number.
maximumDouble
The maximum allowed number.
stepInterval
A step interval to be used for a slider or picker. Default =
nil
.unit
A unit label associated with this property. Default =
nil
.formatter
NumberFormatter
that is appropriate to the data type. Default =nil
. -
Initialize from a
Decoder
.- example:
{ "minimumValue" : 15, "maximumValue" : 360, "stepInterval" : 5, "unit" : "cm", "formatter" : {"maximumDigits" : 3 } }
Throws
DecodingError
Declaration
Swift
public init(from decoder: Decoder) throws
Parameters
decoder
The decoder to use to decode this instance.
-
Encode the object to the given encoder.
Throws
EncodingError
Declaration
Swift
public func encode(to encoder: Encoder) throws
Parameters
encoder
The encoder to use to encode this instance.