joec
joec

Reputation: 3543

Calculate distance between two latitudes/longitudes in MapKit / CoreLocation

Im looking to use the getDistanceFrom method in CoreLocation to determine distance between two points, but i get errors when trying to use CoreLocation...

Im using 3.1.2. I have tried this, but returns an error:

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);

error given:

".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

am i missing something? i have imported CoreLocation...

Is this method deprecated in 3.1.2?

Thanks

Upvotes: 0

Views: 8842

Answers (2)

joec
joec

Reputation: 3543

Solved by removing the framework search directories from the project.pbxproject file inside the Xcode project bundle

Upvotes: 0

konryd
konryd

Reputation: 531

You need to add a CoreLocation framework to the project.

Upvotes: 1

Related Questions