如何用iPhone计算我的速度?

Cod*_*ter 4 iphone ios

可能重复:
如何使用iphone计算我们汽车的速度

如何用iPhone计算我的速度?例如,我可能想要在驾驶时测量我的汽车速度.我该如何实现呢?

Ash*_*lls 11

尝试这样的事情:

- (id) init
{
    self = [super init];
    if (self != nil) {
        self.manager = [[CLLocationManager alloc] init];
        self.manager.delegate = self;
        [self.manager startUpdatingLocation];
    }
    return self;
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    NSLog(@"Speed = %f", newLocation.speed);
}
Run Code Online (Sandbox Code Playgroud)