I use this code to check if I have access to the user location or not
if CLLocationManager.locationServicesEnabled() {
switch CLLocationManager.authorizationStatus() {
case .restricted, .denied:
hasPermission = false
default:
hasPermission = true
}
} else {
print("Location services are not enabled")
}
}
And Xcode(12) yells at me with this warning:
'authorizationStatus()' was deprecated in iOS 14.0
So what is the replacement?
It is now a property of
CLLocationManager
,authorizationStatus
. So, create aCLLocationManager
instance:Then you can access the property from there:
There are a few location related changes in iOS 14. See WWDC 2020 What's new in location.
Needless to say, if you also need to support iOS versions prior to 14, then just add the
#available
check, e.g.: