只是一个关于核心位置的简单问题,我正在尝试计算两点之间的距离,代码如下:
-(void)locationChange:(CLLocation *)newLocation:(CLLocation *)oldLocation
{
// Configure the new event with information from the location.
CLLocationCoordinate2D newCoordinate = [newLocation coordinate];
CLLocationCoordinate2D oldCoordinate = [oldLocation coordinate];
CLLocationDistance kilometers = [newCoordinate distanceFromLocation:oldCoordinate] / 1000; // Error ocurring here.
CLLocationDistance meters = [newCoordinate distanceFromLocation:oldCoordinate]; // Error ocurring here.
}
我在最后两行收到以下错误:
错误:无法转换为指针类型
我一直在谷歌搜索,但找不到任何东西。
试试这个:
CLLocationDistance meters = [newLocation distanceFromLocation:oldLocation];
您尝试使用的方法是CL位置 https://developer.apple.com/documentation/corelocation/cllocation目的 :)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)