Why are the delegate methods for CurrentLotion (CLLocationManager) not called in iOS4.0?

I am using iPhone sdk 4.0. I used the code below to determine the current location, but its delegation methods are not called automatically ... My code is below:

in .hfile

I have import

CoreLocation/CoreLocation.h

also delegate

CLLocationManagerDelegate

CLLocationManager *locationManager;

in .mfile

    locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
[locationManager startUpdatingLocation];

but I do not get the current location for this ...... My delegation method, which is not called:

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{

}
+3
source share
2 answers

Your code looks right to me. Have you also tried running this code on a real iPhone? The simulator does not always respond to location manager updates. There is also another important delegate method that you must add to your .m file:

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

, - . , iPhone.

0

. , .

. .

0

Source: https://habr.com/ru/post/1759838/


All Articles