CLLocationManager在多线程下使用 如果是子线程中创建CLLocationManager,那么startUpdatingLocation后是无法定位的,任何代理函数都不会被调用,而且表面上还会有提示是否定位的MessageBox,一切看起来都正常,就是代理不会执行。

似乎定位的返回(调用代理)只能有主线程来调用,并且这个对象还必须是在主线程创建的。
做过以下实验:
1.子线程中:
        self.locationManager = [[CLLocationManager alloc] init] autorelease];
        locationManager.delegate = self;
        [locationManager startUpdatingLocation];
    结果:不会有任何结果返回。
2.主线程中:
        childThread.locationManager = [CLLocationManager alloc] init];
        [childThread.locationManager release];
        childThread.locationManager.delegate = childThread;
  在子线程中调用:
        [locationManager startUpdatingLocation];
  结果:代理函数会执行,但是是由主线程来调用的。也就是子线程启动定位,主线程返回结果。