将'CLLocationManager *'发送到不兼容类型'CLLocationCoordinate2D'的参数;

时间:2012-07-04 04:30:00

标签: objective-c cocoa-touch core-location mkreversegeocoder

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

下面是代码段:

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 个答案:

答案 0 :(得分:1)

你必须在CLLocation的委托方法中调用location getter,你可以在其中获得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];

}