locationmanager没有名为verbosedictionary的成员

时间:2015-03-21 11:44:20

标签: ios swift locationmanager

当我升级到XCode 6.2时,我的工作代码突然出现此错误

“错误:locationmanager没有名为verbosedictionary的成员”

这是抛出错误的行:             verboseMessage = verboseMessageDictionary[verboseKey]!

------------------ LocationManager.swift中的参考代码

internal func locationManager(manager: CLLocationManager!,
        didChangeAuthorizationStatus status: CLAuthorizationStatus) {
            var hasAuthorised = false
            var verboseKey = status
            switch status {
            case CLAuthorizationStatus.Restricted:
                locationStatus = "Restricted Access"
            case CLAuthorizationStatus.Denied:
                locationStatus = "Denied access"
            case CLAuthorizationStatus.NotDetermined:
                locationStatus = "Not determined"
            default:
                locationStatus = "Allowed access"
                hasAuthorised = true
            }

        verboseMessage = verboseMessageDictionary[verboseKey]!

1 个答案:

答案 0 :(得分:0)

由于某种原因,最新版本的Swift已将CLAuthorizationStatus。授权更改为CLAuthorizationStatus。 AuthorizedAlways ,这在LocationManager.swift中的verboseMessageDictionary声明中引入了错误

进行更改后,错误得到修复。当您有LocationManager并升级到XCode 6.2

时会发生这种情况

希望这有助于其他人!

private let verboseMessageDictionary = [CLAuthorizationStatus.NotDetermined:“您尚未就此应用程序做出选择。”,         CLAuthorizationStatus.Restricted:“此应用程序无权使用位置服务。由于对位置服务的主动限制,用户无法更改此状态,并且可能没有亲自拒绝授权。”,         CLAuthorizationStatus.Denied:“您已明确拒绝此应用程序的授权,或在”设置“中禁用了位置服务。”,         CLAuthorizationStatus.Authorized:“应用程序被授权使用位置服务。”,CLAuthorizationStatus.AuthorizedWhenInUse:“您已授权仅在应用程序对您可见时才使用您的位置。”]