Search for heights in Swift

I'm having trouble finding a way to get the height of the device. Can someone give me a pointer or put together a short script that will get the height of the device and print it out? But fast. Thanks!

+6
source share
1 answer

Import CoreLocation

import CoreLocation 

Create locationManger variable

 var locationManager:CLLocationManager = CLLocationManager() 

Initialize and start updating location

 override func viewDidLoad() { super.viewDidLoad() self.locationManager = CLLocationManager() locationManager.requestWhenInUseAuthorization() self.locationManager.delegate = self self.locationManager.distanceFilter = kCLDistanceFilterNone self.locationManager.desiredAccuracy = kCLLocationAccuracyBest self.locationManager.startUpdatingLocation() } func locationManager(manager: CLLocationManager!, didUpdateToLocation newLocation: CLLocation!, fromLocation oldLocation: CLLocation!) { var alt = newLocation.altitude println("\(alt)") manager.stopUpdatingLocation() } 
+8
source

Source: https://habr.com/ru/post/977693/


All Articles