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开发者_StackOverflow社区];
}
- (void)locationUpdate:(CLLocation *)location {
locLabel.text = [location description];
}
- (void)locationError:(NSError *)error {
locLabel.text = [error description];
}
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.
精彩评论