相关疑难解决方法(0)

distanceFromLocation - 计算两点之间的距离

关于Core Location的一个简单问题,我正在尝试计算两点之间的距离,代码如下:

    -(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.
}
Run Code Online (Sandbox Code Playgroud)

我在最后两行收到以下错误:

错误:无法转换为指针类型

我一直在搜索谷歌,但我找不到任何东西.

objective-c core-location ios

49
推荐指数
4
解决办法
8万
查看次数

如何测量两个CLLocations之间的距离(米)?

我怎样才能得到两米之间的距离CLLocationCLLocation它没有提供任何方法来实现它.

cocoa-touch objective-c core-location cllocation

18
推荐指数
2
解决办法
2万
查看次数