Last active
July 10, 2018 16:41
-
-
Save aclima93/bfd02f3e2060bc645b8311919c53e4dc to your computer and use it in GitHub Desktop.
ARKit & CoreLocation + Current Locaiton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreLocation | |
class ARCLViewController: UIViewController, CLLocationManagerDelegate { | |
var locationManager: CLLocationManager! | |
var latestLocation: CLLocation? | |
func setupLocation() { | |
// Setup location manager | |
locationManager = CLLocationManager() | |
locationManager?.delegate = self | |
// shouldn't need better accuracy for walking between POIs | |
locationManager?.desiredAccuracy = kCLLocationAccuracyNearestTenMeters | |
// request location updates | |
locationManager?.startUpdatingLocation() | |
locationManager?.requestWhenInUseAuthorization() | |
} | |
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { | |
print("LocationManager didFailWithError: %@", error) | |
// TODO: handle error | |
} | |
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { | |
print("LocationManager didUpdateLocations: %@", locations) | |
// handle updated location | |
if (locations.count > 0) { | |
latestLocation = locations.last! | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment