Hi in my iOS app I should fetch CLLocation updates in a background thread hence I have created CLLocation object like follows
dispatch_queue_t globalConcurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(globalConcurrentQueue,^{
objAppDelegate.locationManager.DistanceFilter =Constants.kDISTANCE_FILTER;
objAppDelegate.locationManager.DesiredAccuracy =CLLocation.AccurracyBestForNavigation;
objAppDelegate.locationManager.StartUpdatingLocation ();
});
Is it okay? I read it on some portal, as per apple guidelines we should call CLLocation updates strictly on Main thread, Is that so?
It is not necessary to call the locationManager
from a background thread, most of its call are asynchronous. So it is best to call it from the main thread though not required. Also, it is important to note that whatever thread you start the 'locationmanager' from is the thread its delegates will be called on.
As per the docs:
The methods of your delegate object are called from the thread in which you started the corresponding location services. That thread must itself have an active run loop, like the one found in your application’s main thread.