FormattingRanges

public protocol FormattingRanges

Provides information about what conversion parameters should be used for input value within a specific range

Important

This is a Public Preview API. It may be changed or removed at any time.
  • the array of ranges with corresponding conversion info

    Declaration

    Swift

    var rangesWithRelatedConversionInfo: [RangeConversionInfo] { get }
  • the unit in which ranges are specified

    Declaration

    Swift

    var rangeUnit: UnitLength { get }

FormattingRanges

  • The function modifies the given array of range conversion infos so that the ranges are shifted to favour higher ranges when possible e.g. Having input range conversion array defined like that:

    (100 ..< 1000, ConversionInfo(roundToNearest: 100, outputUnit: .meters)), (1000 ..< 3000, ConversionInfo(roundToNearest: 500, outputUnit: .kilometers)),

    the modified ranges will be shifted so that the upper bound of the range is decreased by half of the rounding step and lower band is decreased by half of rounding step of previous entry (to be the same as previous entry upper bound)

    (100 ..< 950, ConversionInfo(roundToNearest: 100, outputUnit: .meters)), (950 ..< 3000, ConversionInfo(roundToNearest: 500, outputUnit: .kilometers)),

    Declaration

    Swift

    public func modifyRangeConversionInfosToFavourHigherRange(_ rangeConversionInfos: [RangeConversionInfo])
        -> [RangeConversionInfo]

    Parameters

    rangeConversionInfos

    array of range conversion info data to be modified

    Return Value

    array of modified range conversion infos