DistanceFormatter

open class DistanceFormatter: LengthFormatter

Provides appropriately formatted, localized descriptions of linear distances.

  • Indicates the most recently used unit

    Declaration

    Swift

    public private(set) var unit: LengthFormatter.Unit = .millimeter
  • Intializes a new DistanceFormatter.

    Declaration

    Swift

    @objc public init(approximate: Bool = false)

    Parameters

    approximate

    approximates the distances.

  • Returns a more human readable String from a given CLLocationDistance.

    The user’s Locale is used here to set the units.

    Declaration

    Swift

    @objc public func string(from distance: CLLocationDistance) -> String
  • Returns an attributed string containing the formatted, converted distance.

    NSAttributedStringKey.quantity is applied to the numeric quantity.

    Declaration

    Swift

    @objc open override func attributedString(for obj: Any, withDefaultAttributes attrs: [NSAttributedStringKey : Any]? = nil) -> NSAttributedString?