Hello,
I would like to store CLAuthorizationStatus in the User Defaults using the AppStorage property wrapper, so that I can access it throughout the app as a simple variable rather than accessing the authorisation status every time via CLLocationManager which requires to import MapKit.
The problem is that this Enum rawValue Type is an Int32 (instead of Int, e.g. UNAuthorizationStatus), so the following does not work:
throws: Candidate requires that the types 'CLAuthorizationStatus.RawValue' (aka 'Int32') and 'Int' be equivalent (requirement specified as 'Value.RawValue' == 'Int') (SwiftUI.AppStorage)
I tried extending AppStorage to include an initializer with a RawRepresentable that has Int32 as rawValue but I can't find what to include in it to make it work.
Thanks in advance.
I would like to store CLAuthorizationStatus in the User Defaults using the AppStorage property wrapper, so that I can access it throughout the app as a simple variable rather than accessing the authorisation status every time via CLLocationManager which requires to import MapKit.
The problem is that this Enum rawValue Type is an Int32 (instead of Int, e.g. UNAuthorizationStatus), so the following does not work:
Code Block @AppStorage("locationSettings") var locationSettings: CLAuthorizationStatus = CLAuthorizationStatus.notDetermined
throws: Candidate requires that the types 'CLAuthorizationStatus.RawValue' (aka 'Int32') and 'Int' be equivalent (requirement specified as 'Value.RawValue' == 'Int') (SwiftUI.AppStorage)
I tried extending AppStorage to include an initializer with a RawRepresentable that has Int32 as rawValue but I can't find what to include in it to make it work.
Code Block extension AppStorage { init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value : RawRepresentable, Value.RawValue == Int32 { } }
Thanks in advance.