String from distance

suggest change

Given a CLLocationDistance (simply a Double representing meters), output a user-readable string:

let distance = CLLocationDistance(42)
let formatter = MKDistanceFormatter()
let answer = formatter.stringFromDistance(distance)
// answer = "150 feet"


CLLocationDistance distance=42;
MKDistanceFormatter *formatter=[[MKDistanceFormatter alloc]init];
NSString *answer=[formatter stringFromDistance:distance];
// answer = "150 feet"

By default, this respects the user’s locale.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents