I am new to objective c. My program is when start button is pressed, the location coordinates should start tracking and the distance should get tracked simultaneously and when stop button is pressed, the the tracking should stop and the distance should be displayed.
-
[What have you tried?](http://whathaveyoutried.com) What is your question (I don't even see a "?" anywhere) – David Rönnqvist Sep 22 '12 at 10:46
-
My Question was "how to track location coordinates continuously so that i can calculate the distance?" – Sharanya Sep 22 '12 at 11:38
2 Answers
Assuming that you have already added the necessary framework and delegates, created the object CLLocationManager *locationManager; and done all the initialization
When you click your start button call this inside button_clicked method which you should create
[self.locationManager startUpdatingLocation];
When you click your stop button call this
[self.locationManager stopUpdatingLocation];
When your location is updated this delegate method will be automatically called where you can access your new location coordinate
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation;

- 2,807
- 1
- 16
- 18
The CLLocationManagerDelegate helps to achieve this when you set the delegate to self after you have confirmed to it.
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
this method is called each time when your location is changed as a callback function.
Here is a small tutorial that might give you a step by step instruction: http://www.mobisoftinfotech.com/blog/iphone/1474/
I hope it helps you. Cheers!!

- 1,092
- 1
- 9
- 19