首页 > 解决方案 > CLLocationManagerDelegate didFailError 总是回调错误是 CLError 吗?

问题描述

在swift中,CLLocationManagerDelegate didFailWithError错误的方法总是CLError?如果是的话,有什么参考吗?

讨论:发生错误时调用。错误类型在“CLError.h”中定义。

这是否意味着我可以LAError随时将错误转换为?

func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
        guard let error = error as? CLError else {
            // Never?
            return
        }
    }

并且LAError...

标签: iosswiftcllocationmanager

解决方案


当 CLLocationManager 对象无法检索位置时,我在下面找到了错误的合法参考。讨论部分在参考中也有一些示例,说明在不同情况下会收到哪些错误:

https://developer.apple.com/documentation/corelocation/cllocationmanagerdelegate/1423786-locationmanager

希望这对你有帮助!!


推荐阅读