Formatters

MGLClockDirectionFormatter


          @interface MGLClockDirectionFormatter : NSFormatter

The MGLClockDirectionFormatter class provides properly formatted descriptions of headings relative to the user, known as clock positions. For example, a value of 90 may be formatted as “3 o’clock”, depending on the locale.

Use this class to create localized heading strings when displaying directions relative to the user’s current location and heading. To format a direction irrespective of the user’s orientation, use MGLCompassDirectionFormatter instead.

  • unitStyle

    The unit style used by this formatter.

    This property defaults to NSFormattingUnitStyleMedium.

    Declaration

    Objective-C

    @property (nonatomic) NSFormattingUnitStyle unitStyle;

    Swift

    var unitStyle: Formatter.UnitStyle { get set }
  • -stringFromDirection:

    Returns a clock position string for the provided value.

    Declaration

    Objective-C

    - (nonnull NSString *)stringFromDirection:(CLLocationDirection)direction;

    Swift

    func string(fromDirection direction: CLLocationDirection) -> String

    Parameters

    direction

    The heading, measured in degrees, where 0° means “straight ahead” and 90° means “directly to your right”.

    Return Value

    The clock position string appropriately formatted for the receiver’s locale.

  • -getObjectValue:forString:errorDescription:

    This method is not supported for the MGLDirectionFormatter class.

    Declaration

    Objective-C

    - (BOOL)getObjectValue:(out id _Nullable *_Nullable)obj
                           forString:(nonnull NSString *)string
                    errorDescription:(out NSString *_Nullable *_Nullable)error;

    Swift

    func getObjectValue(_ obj: AutoreleasingUnsafeMutablePointer<AnyObject?>?, for string: String, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool

MGLCompassDirectionFormatter


          @interface MGLCompassDirectionFormatter : NSFormatter

The MGLCompassDirectionFormatter class provides properly formatted descriptions of absolute headings. For example, a value of 90 may be formatted as “east”, depending on the locale.

Use this class to create localized heading strings when displaying directions irrespective of the user’s current location. To format a direction relative to the user’s current location, use MGLClockDirectionFormatter instead.

  • unitStyle

    The unit style used by this formatter.

    This property defaults to NSFormattingUnitStyleMedium.

    Declaration

    Objective-C

    @property (nonatomic) NSFormattingUnitStyle unitStyle;

    Swift

    var unitStyle: Formatter.UnitStyle { get set }
  • -stringFromDirection:

    Returns a heading string for the provided value.

    Declaration

    Objective-C

    - (nonnull NSString *)stringFromDirection:(CLLocationDirection)direction;

    Swift

    func string(fromDirection direction: CLLocationDirection) -> String

    Parameters

    direction

    The heading, measured in degrees, where 0° means “due north” and 90° means “due east”.

    Return Value

    The heading string appropriately formatted for the formatter’s locale.

  • -getObjectValue:forString:errorDescription:

    This method is not supported for the MGLDirectionFormatter class.

    Declaration

    Objective-C

    - (BOOL)getObjectValue:(out id _Nullable *_Nullable)obj
                           forString:(nonnull NSString *)string
                    errorDescription:(out NSString *_Nullable *_Nullable)error;

    Swift

    func getObjectValue(_ obj: AutoreleasingUnsafeMutablePointer<AnyObject?>?, for string: String, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool

MGLCoordinateFormatter


          @interface MGLCoordinateFormatter : NSFormatter

The MGLCoordinateFormatter class provides properly formatted descriptions of geographic coordinate pairs. Use this class to create localized coordinate strings when displaying location information to users.

  • allowsMinutes

    Determines whether the output may contain minutes of arc when nonzero.

    The default value of this property is YES, causing the receiver to include minutes of arc in its output. If allowsSeconds is YES, this property is ignored and the output always includes minutes of arc.

    Declaration

    Objective-C

    @property (nonatomic) BOOL allowsMinutes;

    Swift

    var allowsMinutes: Bool { get set }
  • allowsSeconds

    Determines whether the output may contain seconds of arc when nonzero.

    The default value of this property is YES, causing the receiver to include seconds of arc in its output.

    Declaration

    Objective-C

    @property (nonatomic) BOOL allowsSeconds;

    Swift

    var allowsSeconds: Bool { get set }
  • unitStyle

    The unit style used by this formatter.

    The default value of this property is NSFormattingUnitStyleMedium.

    Declaration

    Objective-C

    @property (nonatomic) NSFormattingUnitStyle unitStyle;

    Swift

    var unitStyle: Formatter.UnitStyle { get set }
  • -stringFromCoordinate:

    Returns a coordinate string for the provided value.

    Declaration

    Objective-C

    - (nonnull NSString *)stringFromCoordinate:(CLLocationCoordinate2D)coordinate;

    Swift

    func string(from coordinate: CLLocationCoordinate2D) -> String

    Parameters

    coordinate

    The coordinate’s value.

    Return Value

    The coordinate string appropriately formatted for the formatter’s locale.

  • -getObjectValue:forString:errorDescription:

    This method is not supported for the MGLCoordinateFormatter class.

    Declaration

    Objective-C

    - (BOOL)getObjectValue:(out id _Nullable *_Nullable)obj
                           forString:(nonnull NSString *)string
                    errorDescription:(out NSString *_Nullable *_Nullable)error;

    Swift

    func getObjectValue(_ obj: AutoreleasingUnsafeMutablePointer<AnyObject?>?, for string: String, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool

MGLDistanceFormatter


          @interface MGLDistanceFormatter : NSLengthFormatter

MGLDistanceFormatter implements a formatter object meant to be used for geographic distances. The user’s current locale will be used by default but it can be overriden by changing the locale property of the numberFormatter.

  • -stringFromDistance:

    Returns a localized formatted string for the provided distance.

    Declaration

    Objective-C

    - (nonnull NSString *)stringFromDistance:(CLLocationDistance)distance;

    Swift

    func string(fromDistance distance: CLLocationDistance) -> String

    Parameters

    distance

    The distance, measured in meters.

    Return Value

    A localized formatted distance string including units.