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.tex开发者_StackOverflow中文版t = [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?
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
精彩评论