2012-12-15 58 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通常意味着您經常調用地理位置服務器。通常情況下,每次委託方法執行UpdateUpocations時,都會向服務器發送反向地理編碼請求。在文檔中,蘋果表示這通常應該每分鐘進行一次。

相關問題