0

I was using following code to find distance between 2 points:

CLLocation *location1 = [[CLLocation alloc] initWithLatitude:28.3636 longitude:-77.1212];

CLLocation *location2 = [[CLLocation alloc] initWithLatitude:42.353297 longitude:-71.578858];

float target = [location1 getDistanceFrom:location2];

But now getDistanceFrom is deprecated by Apple.

What should I try to perform same task?

Moshe
  • 56,717
  • 76
  • 267
  • 423
Ranjeet Sajwan
  • 1,916
  • 2
  • 28
  • 60

2 Answers2

6

How about -distanceFromLocation: instead? It's even explicitly mentioned in the documentation on -getDistanceFrom: as the method to use as a replacement.

Lily Ballard
  • 176,187
  • 29
  • 372
  • 338
  • will you please tell me how to set that CLLocationDistance object that this method returns....for my CLLocation object (here location1) – Ranjeet Sajwan Jan 24 '11 at 06:33
2

You want to use 'distanceFromLocation:'. See the documentation for more: http://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html

Moshe
  • 56,717
  • 76
  • 267
  • 423