neotorama
neotorama

Reputation: 138

Get CLLocation coordinate from a method

I follow a tutorial from http://www.vellios.com/2010/08/16/core-location-gps-tutorial/ to make an app to show user's current location. It has a method called 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]];
}

How do i call location.coordinate.latitude outside this method?

Upvotes: 0

Views: 3513

Answers (1)

max_
max_

Reputation: 24481

Make a variable of CLLocation in your .h File, and then set that variable when the location updates (in the below method).

- (void)locationUpdate:(CLLocation *)location

Upvotes: 1

Related Questions