Import CoreLocation library and setup it's delegate methods & helper functions
Wed Jun 02 2021 12:38:53 GMT+0000 (Coordinated Universal Time)
Saved by
@joeavargas
import UIKit
import CoreLocation
class ViewController: UIViewController {
// Properties
let locationManager = CLLocationManager()
var location: CLLocation?
// TODO: Current Weather data model: var currentWeather: Current?
override func viewDidLoad() {
super.viewDidLoad()
// Trigger location services function upon loading
checkLocationServices()
}
}
// MARK: - LocationManager Delegate and Helper Functions
extension ViewController: CLLocationManagerDelegate{
// Setup Location Manager function
func setupLocationManager(){
}
// Check when location services are enabled
func checkLocationServices(){
}
// Get user's GPS coordinates
func getUserCoordinates(){
// Implement network request passing in user's coordinates
DispatchQueue.main.async {
// Setup UI
}
}
// Check for GPS permission authorization
func checkLocationAuthorization(){
}
// Method to trigger when user's location changes
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
// get latest location
// update location when user has moved
}
// Method to trigger when GPS location permission changes
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
}
}
content_copyCOPY
Comments