2013-04-22 2 views
0
+(void) vStartUpdatingLocation 
{ 
    while (false); 
    AssertNonMainThread 
    [[NSOperationQueue mainQueue]addOperationWithBlock:^{ 
     CLLocationHandler * singleton = [CLLocationHandler singleton]; 
     CLLocationManager * locationManager = singleton.locationManager; 
     NSAssert(locationManager.delegate==singleton,@"They are meant for each other"); //Assertion here 
     [locationManager startUpdatingLocation]; //update location 
     PO(singleton.locationManager); 
     PO(singleton.locationManager.delegate); 
     PO(singleton); //verify that locationManager.delegate == singleton 
     while(false); 
    }]; 
} 
- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
      fromLocation:(CLLocation *)oldLocation 
{ 
    AssertMainThread;//break point here never called 
    PO(self.locationManager); 
    PO(manager); 
    while(false); 
    [self finishUpdating]; 
    [self updateCurrentPlaceCache:newLocation]; 
} 
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
{ 
    [self finishUpdating]; //no love here too 
} 

의견에 대한 대부분의 정보를 넣었습니다.didUpdateToLocation과 didFailOnError가 모두 호출되지 않는 이유는 무엇입니까?

내가 locationManager.delegate 실제로 유형 그러나

- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
      fromLocation:(CLLocation *)oldLocation 

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 

가 호출되지

CLLocationHandler

의 싱글 톤 객체임을 확인했습니다. 그것은 일하는 것이 었습니다.

답변

0

performSelectorOnMainThread를 사용하여 위치 관리자를 설정해야합니다. 백그라운드 스레드에서 설정하면 작동하지 않습니다. 실행 루프가 백그라운드 스레드에서 활성화되어 있지 않기 때문에 가능성이 큽니다. Why is my CLLocationmanager delegate not getting called?

+0

굉장합니다. 내가 더 높은 점수를받는다면 나는 투표했을 것입니다. –

관련 문제