how to get current location latitude and longitude.
I have try this. Using Xcode 6.01 and IOS SDK 8.0
-(CLLocationCoordinate2D) getLocation{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
return coordinate;
}
- (void)getCurrentLocation{
CLLocationCoordinate2D coordinate = [self getLocation];
NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude];
NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];
NSLog(@"Latitude = %@", latitude);
NSLog(@"Longitude = %@", longitude);
}
- (void)viewDidLoad{
[super viewDidLoad];
[self getCurrentLocation];
}
Here I enable the simulator location to Deployment 8.0 iPhone simulator 4s. Even on device its not working.
@ALL Please let me know, what i have done wrong here.