views:

264

answers:

3

This is the code that I have in my AppDelegate Class

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.distanceFilter = 1000;  // 1 Km
    locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
    [locationManager startUpdatingLocation];
}

And this is the delegate method i have in my AppDelegate Class

    //This is the delegate method for CoreLocation
- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{

        //printf("AppDelegate latitude %+.6f, longitude %+.6f\n", newLocation.coordinate.latitude, newLocation.coordinate.longitude);

}

Its working in 3.0, 3.1, 3.1.3 , but its not working in 4.0 simulator and device both.

What is the reason ?

A: 

Are you sure you are not deallocating the location manager somewhere? The code you have shows it being allocated in the didFinishLaunching... method but then being forgotten about (though it's still retained and so should still work).

Do you even see that initial popup asking you if it's OK to get the user location?

Kendall Helmstetter Gelner
yes tried every possible solution....do i need to reinstall the iphone SDK ????
Biranchi
+2  A: 

Does -locationManager:didFailWithError: in your delegate ever get called? I'm just thinking, maybe you denied access to location data at some point and now don't get prompted, but access is denied.

Thomas Müller
A: 

Did anyone find a solution for this???

Urs
Its working on the Device iOS4.0 but with 40 seconds delay , while its taking 2/3 seconds on iPhone OS 3.1.2
Biranchi