Reputation: 259
I have added code for finding location, this is working on simulator but it is not working on iPhone device. I have enabled the location services but still it is not working.
-(void)firstTimeRefresh {
CLLocation *bestLocation = [[[AppDelegate getAppDelegate] locationManager] bestLocation];
if ( bestLocation != NULL) {
NSLog(@"Using Best Loaction");
[self getArray: [NSArray arrayWithObjects: [NSNumber numberWithFloat:bestLocation.coordinate.latitude],
[NSNumber numberWithFloat: bestLocation.coordinate.longitude], nil] :@"false":page_no];
}
}
Upvotes: 0
Views: 67
Reputation: 11037
try this code and its working at mine end.
locationManager = [[CLLocationManager alloc] init]; [locationManager setDelegate:self]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [locationManager startUpdatingLocation];
Define the CLLocationManagerDelegate delegate in .h class file when location is updated this function will get called.
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { }
Upvotes: 1