2012-07-04 82 views
0

我正在通過天氣應用教程工作。我無法獲取該位置的反向地理編碼。它不斷收到標題中的錯誤。我知道它告訴我只是堅持如何解決它。將'CLLocationManager *'發送給不兼容類型'CLLocationCoordinate2D'的參數;

繼承人的代碼片段:

if (1) 
{ 
    locationManager.delegate = self; 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
    [locationManager startUpdatingLocation]; 

    MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:locationManager]; 
    geocoder.delegate = self; 
    [geocoder start]; 
} 
else 
{ 
    [self performSelectorInBackground:@selector(showWeatherFor:) withObject:@"95014"]; 
} 

就像我說的,我還在學習,以便一個解釋是,爲什麼你做,你做了什麼漂亮。

回答

1

您必須在CLLocation的委託方法中調用位置獲取器,您可以在其中獲取GPS座標。 MKReverseGeocoder的參數是一個CLLocation而不是CLLocationManager

# pragma mark LocationGetter Delegate Methods 

- (void)newPhysicalLocation:(CLLocation *)location { 

    //Geocoder is started only if a valid location is found. 
    self.reverseGeocoder = [[[MKReverseGeocoder alloc] initWithCoordinate:location] autorelease]; 
    reverseGeocoder.delegate = self; 
    [reverseGeocoder start]; 

} 
+0

如何調用位置獲取器? – heinst

+0

我以爲我開始得到的位置與「startUpdatingLocation」 – heinst

相關問題