Apple Developer Documentation

How to use

import CoreLocation

class VC: ... {
		...
		let locationManager = CLLocationManager()
		
		func viewDidLoad() {
				...
				locationManager.requestWhenInUseAuthorization()
		}
}
  1. import and instance
  2. trigger permission request // pop up screen about ask the user for permission
  3. add info.plist key: privacy-location when ...
    1. value: "Please Allow Permission.."
    2. trigger permission request // pop up screen about ask the user for permission

Untitled

Untitled

  1. use location manager to request location!

    requestLocation()
    startUpdatingLocation()
    ...moniter. ..cl
    

error

2021-09-03 19:45:23.262967+0900 
Clima[25555:1531511] *** Terminating app due to uncaught exception
'NSInternalInconsistencyException', 
reason: 'Delegate must respond to locationManager:didUpdateLocations:'
//MARK: - CLLocationManagerDelegate

extension WeatherViewController: CLLocationManagerDelegate {
    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        print("call the locationManager")
    }
    
    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
        print(error)
    }
}

location check in simulator?

simul ⇒ feature ⇒ location ⇒ custom or bicycle or car or run ..

question

//locationManager.stopUpdatingLocation()
what's mean?