我正在计算设备的速度,我使用了委托方法
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
但是当我在设备上测试时,它没有显示速度,而是总是显示零速度。
使用的代码是
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"\nStarting point=%@",startingpoint);
if (self.startingpoint == nil)
{
self.startingpoint = newLocation;
oldLocation=self.startingpoint;
}
//Calculate speed
double gpsSpeed = newLocation.speed;
}