查找两点之间距离的新方法
我使用以下代码来查找两点之间的距离:
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];
但现在 getDistanceFrom 已被 Apple 弃用。
我应该尝试什么来执行相同的任务?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么
-distanceFromLocation:
怎么样?甚至在-getDistanceFrom:
的文档中明确提到它是用作替换的方法。How about
-distanceFromLocation:
instead? It's even explicitly mentioned in the documentation on-getDistanceFrom:
as the method to use as a replacement.您想使用“距离位置:”。有关更多信息,请参阅文档: http://developer .apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html
You want to use 'distanceFromLocation:'. See the documentation for more: http://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html