一旦找到你的位置,你需要停止更新。加上这个
manager.stopUpdatingLocation()
tableView
extension RestaurantsViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if (locations.count > 0) {
if (location?.coordinate.longitude != locations[0].coordinate.longitude && location?.coordinate.latitude != locations[0].coordinate.latitude) {
location = locations[0]
print("will reload table")
self.tableView.reloadData()
manager.stopUpdatingLocation()
}
}
}
}