开发者

New method to find distance between 2 points

开发者_如何学Go

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?


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜