获得 CLLocationCoordinate2D 的正确方法是什么?
在.h中:
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
在.m
//Called when the location can be obtained
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
//Get the latitude and longitude location
CLLocation *lastLocation = [locations lastObject];
_latitude = [[NSString alloc] initWithFormat:@"%f", lastLocation.coordinate.latitude];
_longitude = [[NSString alloc] initWithFormat:@"%f", lastLocation.coordinate.longitude];
}
是不是这个:
_coordinate = lastLocation.coordinate;
或这个:
_coordinate = manager.location.coordinate;