Мне нужно найти мое текущее местоположение с помощью CoreLocation
, я пробовал несколько методов, но пока мой CLLocationManager
имеет вернул только 0 .. ( 0.000.00.000
).
Вот мой код ( обновлен до работы ):
Импорт :
#import <CoreLocation/CoreLocation.h>
Объявлено :
IBOutlet CLLocationManager *locationManager;
IBOutlet UILabel *latLabel;
IBOutlet UILabel *longLabel;
Функции :
- (void)getLocation { //Called when needed
latLabel.text = [NSString stringWithFormat:@"%f", locationManager.location.coordinate.latitude];
longLabel.text = [NSString stringWithFormat:@"%f", locationManager.location.coordinate.longitude];
}
- (void)viewDidLoad {
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
[locationManager startUpdatingLocation];
}