I want to get the user's location by setting showUserLocation
property of MKMapView
to true
.
If I create a CLLocationManager
and store it in a property, it works just fine.
However if I do not store it, just call requestWhenInUseAuthorization()
on it like this:
if locationManagerStatus != .AuthorizedWhenInUse {
CLLocationManager().requestWhenInUseAuthorization()
}
then it says:
Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.