距离单位
import Mapkit
Set units
to one of .Default, .Metric, .Imperial, .ImperialWithYards
:
formatter.units = .Metric
var answer = formatter.stringFromDistance(distance)
// "40 m"
formatter.units = .ImperialWithYards
answer = formatter.stringFromDistance(distance)
// "50 yards"
Objective-C
MKDistanceFormatter *formatter=[[MKDistanceFormatter alloc]init];
formatter.units=MKDistanceFormatterUnitsMetric;
NSString *answer=[formatter stringFromDistance:distance];
//40 m
formatter.units=MKDistanceFormatterUnitsImperialWithYards;
NSString *answer=[formatter stringFromDistance:distance];
//50 yards