I want to create a property with CLLocation's longitude and latitude. I tried adding lazy before the variable. There is no error, but the longitude and latitude results are not applied to the attributes. I made a func and tried to use it but it's no use. It just throws an error saying it found nil.
What is the problem? I tried to solve it by myself for a long time, but It is too difficult for me who started studying. I need your kind help.
CLLocation in Swift please help.
`import UIKit import MapKit import CoreLocation import Foundation
class GetLocation: UIViewController, CLLocationManagerDelegate { // var isLocationEnabled = false var locationManager: CLLocationManager! var lat: Double = 1 var lon: Double = 1 var region = CLLocation(latitude: lat, longitude: lon) // let geoCoder = CLGeocoder() override func viewDidLoad() { super.viewDidLoad() self.locationManager = CLLocationManager() self.locationManager?.delegate = self } func regionManager() { self.locationManager.desiredAccuracy = kCLLocationAccuracyBest self.locationManager.requestAlwaysAuthorization() if CLLocationManager.locationServicesEnabled() { print("Location Enabled") } else { print("Location Not Enabled") } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { let location = locations[0] as CLLocation let latitube = location.coordinate.latitude let longitube = location.coordinate.longitude lat = latitube lon = longitube } }