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.

  • The unit style used by this formatter.

    This property defaults to NSFormattingUnitStyleMedium.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSFormattingUnitStyle unitStyle;

    Swift

    var unitStyle: Formatter.UnitStyle { get set }
  • 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.

  • 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