CoreLocation Framework - Aktuelle Position ermitteln

  • CoreLocation Framework - Aktuelle Position ermitteln

    Hallo,

    ich versuche seit gestern mir mit dem CoreLocation Framework die aktuelle Position in Längen und Breitengrad zu ermitteln.

    Ich habe mir dazu mehrere Beispiele rausgesucht und es dann so umgesetzt.
    Das CoreLocation.framework ist eingebunden und auch das CLLocationManagerDelegate ist in dem ViewController hinterlegt.

    Ich habe mir für den locationManager dann eine Property hinzugefügt: @property (nonatomic,strong) CLLocationManager *locationManager;

    In der viewDidLoad Methode ist dann folgendes enthalten:

    Quellcode

    1. if ([CLLocationManager locationServicesEnabled]) {
    2. self.locationManager = [[CLLocationManager alloc] init];
    3. self.locationManager.delegate = self;
    4. [self.locationManager startUpdatingLocation];
    5. NSLog(@"Location services are enabled");
    6. } else {
    7. NSLog(@"Location services are not enabled");
    8. }
    Und dann noch die Funktion die das delegate aufrufen sollte.


    Quellcode

    1. - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
    2. {
    3. NSLog(@"Delegate-Funktion wurde aufgerufen");
    4. CLLocation *location = [locations lastObject];
    5. self.latLabel.text = [NSString stringWithFormat:@"%f", location.coordinate.latitude];
    6. self.lonLabel.text = [NSString stringWithFormat:@"%f", location.coordinate.longitude];
    7. }

    Wie man sich vermutlich schon denken kann wird die die delegate Funktion nicht aufgerufen, in der viewDidLoad scheint aber alles zu funktionieren da erhalte ich jedes mal "Location services are enabled." als Log Ausgabe.


    Hat jemand eine Idee was ich falsch mache?