I am trying to get the coordinates of my location.
I am stackoverflowed, so I am encoded below:
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
self.longitude=coordinate.longitude;
self.latitude=coordinate.latitude;
NSLog(@"dLongitude : %f",self.longitude);
NSLog(@"dLatitude : %f", self.latitude);
But I always get 0 all the time. Incorrect code? or didn’t I set my sim for GPS location?
I don’t understand why I am having problems getting coordinates.
source
share