计算MapKit / CoreLocation中两个纬度/经度之间的距离

时间:2009-12-07 00:13:29

标签: core-location

我希望在CoreLocation中使用getDistanceFrom方法来确定两点之间的距离,但在尝试使用CoreLocation时出错...

我正在使用3.1.2。我试过这个,但是返回一个错误:

CLLocation *userLoc = [[CLLocation alloc] initWithCoordinate:appDelegate.mapView2.userLocation.coordinate];
CLLocation *poiLoc = [[CLLocation alloc] initWithLatitude: [aPOI.latitude doubleValue] longitude: [aPOI.longitude doubleValue]];

double dist = [userLoc getDistanceFrom:poiLoc] / 1000;

NSLog(@"%d",dist);

错误:

".objc_class_name_CLLocation", referenced from:
literal-pointer@__OBJC@__cls_refs@CLLocation in POIDetailViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
我错过了什么吗?我已导入CoreLocation ...

这种方法在3.1.2中是否已弃用?

由于

2 个答案:

答案 0 :(得分:1)

您需要将CoreLocation框架添加到项目中。

答案 1 :(得分:0)

通过从Xcode项目包中的project.pbxproject文件中删除框架搜索目录来解决此问题