Steps to basic geolocation:

1. Add CLLocation framework to Build Phases, Link Binary with Libraries

2. Set up instance variable in .h file:

CLLocationManager *locationManager;


3. Instantiate and set up location manager in the .m file:

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;

4. Inside the button handler:

[locationManager startUpdatingLocation];


This tells the location manager to start updating.

5. This function gets called by the location manager. It is like a callback. The location manager will call this function every time the location is updated.

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
    CLLocation *currentLocation = newLocation;
    NSLog(@"%@", currentLocation);

All this does in this case is dump the data to the debug window.

iPhone: CLLocation: Get current location