سؤال

I want to obtain the current geolocation for my iOS app and look the CLLocationManagerDelegate document for the method locationManager:didUpdateLocations:. In the discussion section, it mentions that If updates were deferred or if multiple locations arrived before they could be delivered, the array may contain additional entries. I don't quite understand in what circumstance the updates will be deferred and other other locations data I might expect from the additional entries.

The sample codes I checked are still using the Deprecated method locationManager:didUpdateToLocation:fromLocation:.

Could someone elaborate?

هل كانت مفيدة؟

المحلول

When the app's in the background, you can defer location updates to conserve battery life:

In iOS 6 and later, you can defer the delivery of location data when your app is in the background. It is recommended that you use this feature in situations where your app could process the data later without any problems. For example, an app that tracks the user’s location on a hiking trail could defer updates until the user hikes a certain distance and then process the points all at once. Deferring updates helps save power by allowing your app to remain asleep for longer periods of time.

In that case, instead of receiving an array with just one CLLocation, the array will contain multiple locations.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top