2012-07-04 31 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

相关问题