Guest User

Untitled

a guest
Jul 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import UIKit
  2. import CoreLocation
  3. class ViewController: UIViewController, CLLocationManagerDelegate{
  4.  
  5. var locationManager = CLLocationManager()
  6. override func viewDidLoad() {
  7. super.viewDidLoad()
  8.  
  9. locationManager.delegate = self
  10. locationManager.desiredAccuracy = kCLLocationAccuracyBest
  11. locationManager.requestWhenInUseAuthorization()
  12. locationManager.startUpdatingLocation()
  13. }
  14. func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
  15. let location = locations[locations.count-1]
  16. print("longitude : \(location.coordinate.longitude), latitude: \(location.coordinate.latitude)")
  17. }
  18. }
Add Comment
Please, Sign In to add comment