iOS Dev/iOS
[iOS/Swift] 'authorizationStatus()' was deprecated in iOS 14.0 초간단 해결
지위프트
2024. 1. 25. 12:05
반응형
[iOS/Swift] 'authorizationStatus()' was deprecated in iOS 14.0 초간단 해결
저는 위와 같이 코드를 사용해서 위치 권한 상태에 따른 팝업을 보여주도록 하였습니다.
하지만 iOS 14부터는 authorizationStatus()가 Deprecated 되기 때문에 수정을 진행하려고 합니다. 앱 최소 지원 iOS가 15이기 때문에 OS에 따른 분기는 없이 처리할 수 있습니다.
CLLocationManager.authorizationStatus()
기존에는 이렇게 사용하던 코드를
CLLocationManager().authorizationStatus
이렇게 변경하면 됩니다. 소괄호를 CLLocationManager로 옮겨주기만 하면 됩니다.
아래는 사용 예시입니다.
// 방법 1
let manager = CLLocationManager()
switch manager.authorizationStatus {
case .restricted, .denied:
...
default:
...
}
// 방법 2
switch CLLocationManager().authorizationStatus {
case .restricted, .denied:
...
default:
...
}
swift - AuthorizationStatus for CLLocationManager is deprecated on iOS 14 - Stack Overflow
AuthorizationStatus for CLLocationManager is deprecated on iOS 14
I use this code to check if I have access to the user location or not if CLLocationManager.locationServicesEnabled() { switch CLLocationManager.authorizationStatus() { case .restricted, .
stackoverflow.com
반응형