location manager was created on a dispatch queue

后端 未结 3 788
余生分开走
余生分开走 2021-01-02 05:45

what does this message mean?

NOTICE,A location manager (0xe86bdf0) was created on a dispatch queue executing on a thread other than the main thread. It is the devel

3条回答
  •  攒了一身酷
    2021-01-02 06:20

    It means that if you created a location manager in another thread besides the "Main" thread (i.e., the thread where all the UI code for you app executes), you need to make sure to always call it (i.e., the location manager) from the thread that created it.

    To debug the problem in your code, you might want to wrap the creation of (and the calls to )the location manager inside a dispatch queue for the main thread thusly:

    dispatch_sync(dispatch_get_main_queue(),^ {
        self.locationManager = [[CLLocationManager alloc] init];
        self.locationManager.delegate = self;
    });
    

    and:

    dispatch_sync(dispatch_get_main_queue(),^ {
      [self.locationManager startUpdatingLocation];
    });
    

    Or something like that to see if the error message goes away.

提交回复
热议问题