I am using a real device to get my current location the problem is the locationManager.location
is nil
and the function didUpdateLocations
is not called.
var location = CLLocationManager()
@IBOutlet weak var map: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
map.showsPointsOfInterest = true
map.showsScale = true
map.showsUserLocation = true
locationManagerConfiguration()
}
func locationManagerConfiguration(){
location.requestAlwaysAuthorization()
location.requestWhenInUseAuthorization()
if CLLocationManager.locationServicesEnabled(){
location.delegate = self
location.desiredAccuracy = kCLLocationAccuracyBest
location.startUpdatingLocation()
}
let sourceCoordinates = location.location?.coordinate
let sourcePlacemark = MKPlacemark(coordinate: sourceCoordinates!
here is the problem the sourceCoordinate is nil