Russell Broadbent

Yorkshire based web developer

iOS4 – Maps, significant change location service

There are two methods for determining a users location in iOS4. The first is to use the ‘standard location service’ by calling the following:

- (void)startStandardUpdates
{
    // Create the location manager if this object does not
    // already have one.
    if (nil == locationManager)
        locationManager = [[CLLocationManager alloc] init];

    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;

    // Set a movement threshold for new events.
    locationManager.distanceFilter = 500;

    [locationManager startUpdatingLocation];
}

This method however should only really be used when you require very precise location updates from the device as it is very power intensive.

The second and preferred method for getting a users location would be to use the ‘significant update service’ using a method similar to the following:

- (void)startSignificantChangeUpdates
{
    // Create the location manager if this object does not
    // already have one.
    if (nil == locationManager)
        locationManager = [[CLLocationManager alloc] init];

    locationManager.delegate = self;
    [locationManager startMonitoringSignificantLocationChanges];
}

Reference taken from here

Comments are closed.