I am new to IOS now I am developing location app i am not getting correct latitude,longitude values while running my app in iPhone.. it gives me too far lat,long values to the current location why it shows me these values can anyone tell me..
Asked
Active
Viewed 171 times
0
-
possible duplicate of [Trouble with CLLocation method distanceFromLocation: Inaccurate results](http://stackoverflow.com/questions/10184802/trouble-with-cllocation-method-distancefromlocation-inaccurate-results) – progrmr Jan 31 '13 at 23:15
1 Answers
0
Try it....
Set Delegate CLLocationManagerDelegate
#import <CoreLocation/CoreLocation.h>
CLLocationManager *locationManager;
CLLocation *startLocation;
- (void)viewDidLoad {
[super viewDidLoad];
NSString *currentLatitude;
NSString *currentLongitude;
locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
startLocation = nil;
}
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
currentLatitude = [[NSString alloc]
initWithFormat:@"%g",
newLocation.coordinate.latitude];
currentLongitude = [[NSString alloc]
initWithFormat:@"%g",
newLocation.coordinate.longitude];
NSLog(@"%@",currentLatitude);
NSLog(@"%@",currentLongitude);
}
-(void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"ERROR" message:[NSString stringWithFormat:@"%@",error] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}

Chirag Pipaliya
- 1,281
- 12
- 20