Reputation: 1
I implement the following code in viewDidLoad
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
and i try to get my location every second via
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
NSLog(@"[%f,%f]",coordinate.latitude,coordinate.longitude);
i try to set the custom location in the iOS simulator, but the location never get updated, i had also tried it on my iphone device and it seems it only capture the first location and subsequent location is not been updated.
Please advise me on how to resolve it
Upvotes: 0
Views: 466
Reputation: 3663
Try this method to get continuous updated latitude and longitude
(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *location_updated = [locations lastObject];
NSLog(@"updated coordinate are %@",location_updated);
}
Upvotes: 1