MKDistanceFormatter uses current locale rather than locale property

Originator:haugli
Number:rdar://28263995 Date Originated:09/12/16
Status:Open Resolved:
Product:iOS SDK Product Version:10.0 (14A345)
Classification:Other Bug Reproducible:Always
 
Summary:
In iOS 10, if you give MKDistanceFormatter a custom locale via -[MKDistanceFormatter setLocale:], it ignores it and uses -[NSLocale currentLocale] instead.

In iOS 9 and below, it uses -[MKDistanceFormatter locale] as expected.

Steps to Reproduce:
Run the following code in iOS 10 with the system locale set to English (U.S.):

    MKDistanceFormatter *distanceFormatter = [[MKDistanceFormatter alloc] init];
    distanceFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"fr_FR"];

    NSString *expectedFormattedDistance = @"2,5 km";
    NSString *actualFormattedDistance = [distanceFormatter stringFromDistance:2500];

    NSLog(@"%@ == %@? %@", actualFormattedDistance, expectedFormattedDistance, [actualFormattedDistance isEqualToString:expectedFormattedDistance] ? @"PASS" : @"FAIL");

A sample Xcode project is attached.

Expected Results:
The console log contains the following output:

MKDistanceFormatterLocaleTest[27902:599694] 2,5 km == 2,5 km? PASS


Actual Results:
The console log contains the following output:

MKDistanceFormatterLocaleTest[27902:599694] 2.5 km == 2,5 km? FAIL


Version:
10.0 (14A345)

Notes:


Configuration:
iOS 10 Simulator

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!