Получить координату CLLocation из метода - PullRequest
0 голосов
/ 10 марта 2011

Я следую руководству от http://www.vellios.com/2010/08/16/core-location-gps-tutorial/, чтобы создать приложение для отображения текущего местоположения пользователя.У него есть метод с именем locationUpdate

- (void)locationUpdate:(CLLocation *)location {
    //locLabel.text = [location description];
    speedLabel.text = [NSString stringWithFormat:@"SPEED: %f", [location speed]];
    latitudeLabel.text = [NSString stringWithFormat:@"LATITUDE: %f", location.coordinate.latitude];
    longitudeLabel.text = [NSString stringWithFormat:@"LONGITUDE: %f", location.coordinate.longitude];
    altitudeLabel.text = [NSString stringWithFormat:@"ALTITUDE: %f", [location altitude]];
}

Как мне вызвать location.coordinate.latitude вне этого метода?

1 Ответ

1 голос
/ 10 марта 2011

Создайте переменную CLLocation в своем файле .h, а затем установите эту переменную при обновлении местоположения (в приведенном ниже методе).

- (void)locationUpdate:(CLLocation *)location

...