I have currently this setup and I would love to change from Km to Miles in calculating distance. Here's my current code:
CLLocation *userloc = [[CLLocation alloc] initWithLatitude:locationManager.location.coordinate.latitude longitude:locationManager.location.coordinate.longitude];
CLLocation *loc = [[CLLocation alloc] initWithLatitude:lat longitude:lon];
CLLocationDistance distance2 = [userloc distanceFromLocation:loc]/ 1000;
NSLog(@"%f",distance2);
[distance setText:[NSString stringWithFormat:@"%.2f km", distance2]];
}
It's a simple conversion:
CLLocationDistance distance2 = [userloc distanceFromLocation:loc] * 0.000621371;
NSLog(@"%f",distance2);
[distance setText:[NSString stringWithFormat:@"%.2f mi", distance2]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With