[ios, osx] Split MGLDirectionFormatter in two

Split MGLDirectionFormatter into MGLClockDirectionFormatter, which specializes in clock positions, and MGLCompassDirectionFormatter, which boxes the compass. This neatly avoids any confusion that might arise if the developer fails to read the documentation and thinks the original unified formatter can convert between the two types of directions.
This commit is contained in:
Minh Nguyễn
2016-04-22 11:12:27 -07:00
committed by Minh Nguyễn
parent e5c6cfde4b
commit 2a1a5f0885
12 changed files with 278 additions and 205 deletions

View File

@@ -0,0 +1,52 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import "MGLTypes.h"
NS_ASSUME_NONNULL_BEGIN
/**
The `MGLClockDirectionFormatter` class provides properly formatted descriptions
of headings relative to the user, known as <i>clock positions</i>. 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.
*/
@interface MGLClockDirectionFormatter : NSFormatter
/**
The unit style used by this formatter.
This property defaults to `NSFormattingUnitStyleMedium`.
*/
@property (nonatomic) NSFormattingUnitStyle unitStyle;
/**
The locale of the receiver.
The locale determines the output language and numeral system of the output.
*/
@property (copy) NSLocale *locale;
/**
Returns a clock position string for the provided value.
@param direction The heading, measured in degrees, where 0° means “straight
ahead” and 90° means “directly to your right”.
@return The clock position string appropriately formatted for the receiver’s
locale.
*/
- (NSString *)stringFromDirection:(CLLocationDirection)direction;
/**
This method is not supported for the `MGLDirectionFormatter` class.
*/
- (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error;
@end
NS_ASSUME_NONNULL_END