How to find the current location of the iPhone and update it

advertisements

I am new to iphone development.I am creating a map application. I have created tool bar with a button below the mapview.When i click the button it should display a alert view showing the current location and asking to update. on clicking OK in alert view should open my map with the current location and CANCEL to close the alert view.The button action is defined in the method

 -(IBAction) gosearch : (id) sender{
    NSLog(@"inside go search");

  }

What should i do to achieve my task.I have added core location framework.But i dont know how to proceed.I saw some inbuilt methods to be used from this link http://iappdevs.blog.co.in/2008/12/06/get-current-location-sample-example-iphone-programming/ but i am not able to implement it.Please guide me.Thanks.


Where does your problem start - have you got a core location delegate that gets location updates? You need to start core location using these methods:

In applicationdidfinishingLauncing()

{
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self; // Tells the location manager to send updates to this object
[locationManager startUpdatingLocation];

This will get core location to call you back as it gets updates on the location, starting with a rough location but further updates should get you a more accurate focus.