开发者

Get CLLocation coordinate from a method

开发者 https://www.devze.com 2023-02-16 14:34 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消