Я использую Xcode 10 и iOS 12
Я получаю это предупреждение для каждого из методов делегата, закодированных в расширении класса моего синглтона CLLocationManager:
locationManager метод экземпляра(: didChangeAuthorization :) 'почти соответствует необязательному требованию' locationManager (: didChangeAuthorization :) 'протокола' CLLocationManagerDelegate '
Вот код:
import Foundation
import CoreLocation
public class PhysicalLocationManager: NSObject {
/*--------------------------------------------------------------------------------*/
//MARK: - Create Singleton Shared Instance
/*--------------------------------------------------------------------------------*/
static let sharedInstance: PhysicalLocationManager = {
let instance = PhysicalLocationManager()
return instance
}()
let locationMgr: CLLocationManager
/*--------------------------------------------------------------------------------*/
//MARK: - Initialization
/*--------------------------------------------------------------------------------*/
override init() {
locationMgr = CLLocationManager()
locationMgr.distanceFilter = kCLDistanceFilterNone
locationMgr.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
super.init()
locationMgr.delegate = self
}
func enableBasicLocationServices() {
switch CLLocationManager.authorizationStatus() {
case .notDetermined:
// Request when-in-use authorization initially
locationMgr.requestWhenInUseAuthorization()
break
case .restricted, .denied:
// Disable location features
// TODO: disableMyLocationBasedFeatures()
break
case .authorizedWhenInUse, .authorizedAlways:
// Enable location features
enableWhenInUseFeatures()
break
}
}
func enableWhenInUseFeatures() {
locationMgr.startUpdatingLocation()
if CLLocationManager.locationServicesEnabled() {
locationMgr.requestLocation()
}
}
}
extension PhysicalLocationManager: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
print("\(manager)\tCLLocationManager, didChangeAuthorization\n\(status)")
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("\(manager)\tCLLocationManager, didUpdateLocations\n\(locations)")
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error)
// locationManager.stopUpdatingLocation()
}
}
Можеткто-нибудь видит, что я здесь делаю неправильно?
Спасибо,