D
Size: a a a
K
K
K
UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
let locationManager = CLLocationManager()
override
func viewDidLoad() {
super.viewDidLoad()
locationManager.requestWhenInUseAuthorization()
locationManager.delegate =
self
locationManager.requestLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if
let location = locations.first {
let coordinate = location.coordinate
print("Lat: \(coordinate.latitude), Long: \(coordinate.longitude)")
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error.localizedDescription)
}
}
ъK
K
K
I
delegate = delegate
явно не упрощают пониманиеK
locationManager.startUpdatingLocation()
K