How can I calculate my speed with iPhone?

Possible duplicate:
How to calculate the speed of our car using iphone

How can I calculate my speed with iPhone? For example, I could measure the speed of my car while driving. How to implement this?

+3
source share
2 answers

Try something like this:

- (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);
}
+10
source

1> You can use GPS Use location services to get latitude and longitude at a specific point in time, and you can get the same after a certain period of time. For example, you can get the distance traveled from latitude and longitude, and divide it by the accepted speed

See Apple GPS Document

2 > , , .

. - Apple

0

All Articles