Search code examples
iosobjective-cios6cllocationmanagercllocationdistance

iOS 6 CLLocationManager last location


So, as of iOS 6, -locationManager:didUpdateToLocation:fromLocation: is deprecated.

Apple suggests, instead, using -locationManager:didUpdateLocations:, which provides anywhere from one to a series of recent location changes. However, in the incredibly likely chance it provides a locations array of length 1, there appears to be no way to access the fromLocation:(CLLocation *)oldLocation parameter of old.

Is there a way to get at this information without using deprecated methods?


Solution

  • You just need to set a property to the value that locationManager:didUpdateLocations: returns, which you can use as the fromLocation, and then call the method again, and use what it returns as the toLocation.