0

我正在学习天气应用教程。我无法获取该位置的反向地理编码。它不断收到标题中的错误。我明白它告诉我的只是坚持如何解决它。

下面是代码片段:

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"];
}

就像我说的,我还在学习,所以解释一下你为什么做了你所做的事情会很好。

4

1 回答 1

1

您必须在获取 gps 坐标的 CLLocation 的委托方法中调用 location getter。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];

}
于 2012-07-04T05:16:15.787 回答