Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
        }
like image 605
Ian Vink Avatar asked Jul 26 '26 15:07

Ian Vink


1 Answers

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.

like image 67
Dimitris Tavlikos Avatar answered Jul 28 '26 05:07

Dimitris Tavlikos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!