关于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)
我在最后两行收到以下错误:
错误:无法转换为指针类型
我一直在搜索谷歌,但我找不到任何东西.
我在CLLocationDistance类型的变量中有距离我需要将它转换为整数变量我该怎么做
我有用
CLLocationDistance kilometers;
int distance = [kilometers intValue];
Run Code Online (Sandbox Code Playgroud)
但它给出了错误.
帮帮我们