DistanceFormatter
@objc(MBDistanceFormatter)
public 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
-
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 givenCLLocationDistance
.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 public override func attributedString(for obj: Any, withDefaultAttributes attrs: [NSAttributedStringKey : Any]? = nil) -> NSAttributedString?