2012-12-15 4 views
2

역 지오 코딩 기능이있는 iOS 앱을 개발하고 있습니다. 함수를 처음 호출하면 모든 것이 정상입니다. 두 번째 호출 (호출이 완료된 컨트롤러의 새 인스턴스 사용) "Domain = kCLErrorDomain Code = 2"오류가 나타납니다. 이것은 시뮬레이터와 장치에서 발생합니다. 좌표는 유효합니다. 내 코드 : 사전에CLGeocoder reverseGeocodeLocation "kCLErrorDomain error 2"

CLGeocoder *geoCoder = [[CLGeocoder alloc] init]; 
CLLocation *loc = [[CLLocation alloc] initWithLatitude:cityCoords.latitude longitude:cityCoords.longitude]; 

self.displayedCity = [[Stadt alloc] init]; 
[geoCoder reverseGeocodeLocation:loc completionHandler:^(NSArray *placemarks, NSError *error) { 

    if(!error){ 
     for (CLPlacemark * placemark in placemarks) { 
      self.displayedCity.name   = [placemark locality]; 
      self.displayedCity.stadtCoord = placemark.region.center; 
     } 

     [self loadCity:self.displayedCity.name]; 

    } 
    else{ 
     NSLog(@"failed getting city: %@", [error description]); 
    } 

}]; 

감사합니다! 다음은이 오류에

+0

답변을 받으셨습니까? –

답변

1

더 많은 정보는 kCLErrorDomain에 애플의 문서에서 찾을 수 있습니다 : Core Location Constants ReferenceCLError.h에 :

kCLErrorNetwork 네트워크는 이용할 수 없었다 또는 네트워크 오류가 발생했습니다.

3

오류 2는 일반적으로 Geolocation 서버를 너무 자주 호출했다는 의미입니다. 대개 이는 위임 메소드 didUpdateLocations가 실행될 때마다 서버에 역 지오 코딩 요청을 보낼 때 발생합니다. 문서에서 Apple은 일반적으로 1 분에 한 번만 수행해야한다고 말합니다.

관련 문제