Ian Vink
Ian Vink

Reputation: 68790

MonoTouch: CLLocationManagerDelegate UpdatedLocation

The UpdatedLocation in CLLocationManagerDelegate is now obsolete.

How would I get this functionality and under what new function call?

OLD:

        public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
        {
            manager.StopUpdatingLocation ();
            locationManager = null;
            callback (newLocation);
        }

Upvotes: 3

Views: 650

Answers (1)

Dimitris Tavlikos
Dimitris Tavlikos

Reputation: 8170

Starting with iOS 6, you have to override the LocationsUpdated method in your delegate:

public override void LocationsUpdated (CLLocationManager manager, CLLocation[] locations)
{
    // Code
}

The locations parameter will always contain at least one CLLocation object and the most recent location will be the last item in the array:

CLLocation recentLocation = locations[locations.Length - 1];

If your app supports iOS 5, you can keep the UpdatedLocation method. No other changes are needed, the same things apply when you call StartUpdatingLocation and StopUpdatingLocation.

This is explained in Apple's documentation on CLLocationManager's startUpdatingLocation method here.

Upvotes: 3

Related Questions