Created
September 5, 2018 18:01
-
-
Save davidseek/3b4916f36eb9b260e40c773ca4bd4275 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class ViewController: UIViewController { | |
| // - Outlets | |
| @IBOutlet weak var locationLabel: UILabel! | |
| // - Constants | |
| private let locationManager = LocationManager() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| guard let exposedLocation = self.locationManager.exposedLocation else { | |
| print("*** Error in \(#function): exposedLocation is nil") | |
| return | |
| } | |
| self.locationManager.getPlace(for: exposedLocation) { placemark in | |
| guard let placemark = placemark else { return } | |
| var output = "Our location is:" | |
| if let country = placemark.country { | |
| output = output + "\n\(country)" | |
| } | |
| if let state = placemark.administrativeArea { | |
| output = output + "\n\(state)" | |
| } | |
| if let town = placemark.locality { | |
| output = output + "\n\(town)" | |
| } | |
| self.locationLabel.text = output | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment