#import "ViewController.h"
#import <CoreLocation/CoreLocation.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
CLLocation *beijinLocation = [[CLLocation alloc]initWithLatitude:39.54 longitude:116.28];
CLLocation *shanghaiLocation = [[CLLocation alloc]initWithLatitude:31.14 longitude:121.29];
//打印两点间的直线距离(默认为米)
NSLog(@"%f 千米",[beijinLocation distanceFromLocation:shanghaiLocation] / 1000);
}
@end