tags:

views:

31

answers:

1

Below is my code but its not working. Can anyone help me???

- (void)viewDidLoad {
    [super viewDidLoad];

   CLController = [[CoreLocationController alloc] init];
   CLController.delegate = self;
   //[CLController setDesiredAccuracy:kCLLocationAccuracyBest]; 
   [CLController.locMgr startUpdatingLocation];
}

- (void)locationUpdate:(CLLocation *)location {
   locLabel.text = [location description];
}

- (void)locationError:(NSError *)error {
   locLabel.text = [error description];
}
A: 

You aren't doing the CLocationManager delegate methods properly

(void)locationUpdate:(CLLocation *)location {
   locLabel.text = [location description]; 
 }

Should be

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation     *)newLocation fromLocation:(CLLocation *)oldLocation{
 locLabel.text = [newLocation description];
}

You should read Apple's documentation http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManagerDelegate_Protocol/CLLocationManagerDelegate/CLLocationManagerDelegate.html%23//apple_ref/doc/uid/TP40007124 about this thoroughly before implementing it.

Robert Redmond