I am trying to get the current longitude and latitude right before the table loads and use the coordinates to make an HTTP request to get a list of nearby locations to display in a table. Right now, I am calling startUpdatingLocation in viewWillLoad, which is too late. My problem is that I can’t seem to get the locations before the table loads, and as a result, the coordinates that are sent in the request are always (0,0).
What would be a better way to approach this?
Thank you!
When you call startUpdatingLocation a delegate is called every few seconds. At this point you could grab the data and then tell your table to reload.
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
In here you would update your data store then you would call [tableView reloadData].