我们可以在后台线程上创建 CLLocation 更新吗?

Can we create CLLocation updates on background thread?

嗨,在我的 iOS 应用程序中,我应该在后台线程中获取 CLLocation 更新,因此我创建了 CLLocation 对象,如下所示

  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 ();

    });

还好吗?我在一些门户网站上读到它,根据苹果指南,我们应该严格在主线程上调用 CLLocation 更新,是这样吗?

不需要从后台线程调用locationManager,它的大部分调用都是异步的。所以最好从主线程调用它,尽管不是必需的。此外,重要的是要注意,无论您从哪个线程启动 'locationmanager' 都是将调用其委托的线程。

根据文档:

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.