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) { } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter