A utility object that converts between a geographic distance and a string-based expression of that distance.


class MKDistanceFormatter : Formatter


You use a distance formatter when you need to display distances to the user or when you want to parse user-specified text to obtain a numerical value for a distance. When formatting strings containing distances, a distance formatter object takes into account the user’s locale and language settings. You can also specify a custom locale or custom units for any distances that you format.


Converting Distances

func string(fromDistance: CLLocationDistance) -> String

Creates a string representation of the specified distance.

func distance(from: String) -> CLLocationDistance

Returns the distance value parsed from the specified string.

Specifying the Format

var locale: Locale!

The locale to use when formatting strings.

var units: MKDistanceFormatter.Units

The measuring system (imperial or metric) to use for units.

enum MKDistanceFormatter.Units

Constants that reflect the type of units to use in the string.

enum MKDistanceFormatter.DistanceUnitStyle

Constants that indicate the format style to use for strings.


Inherits From

Conforms To

See Also

Map Coordinates

struct MKCoordinateRegion

A rectangular geographic region centered around a specific latitude and longitude.

struct MKCoordinateSpan

The width and height of a map region.

struct MKMapRect

A rectangular area on a two-dimensional map projection.

struct MKMapPoint

A point on a two-dimensional map projection.

struct MKMapSize

Width and height information on a two-dimensional map projection.