简体   繁体   English

类型'AppDelegate'不符合协议'CLLocationManagerDelegate' - Xcode 6中的Swift

[英]Type 'AppDelegate' does not conform to protocol 'CLLocationManagerDelegate' - Swift in Xcode 6

I am trying to use the significant-change location service . 我正在尝试使用重要更改位置服务 I am using Swift with XCode on OS Mavericks. 我在OS Mavericks上使用Swift和XCode。 I am attempting to enhance an iOS app that I built following a tutorial. 我正在尝试增强我按照教程构建的iOS应用程序。

In my AppDelegate.swift file I have created the following method to initialise my location manager service: 在我的AppDelegate.swift文件中,我创建了以下方法来初始化我的位置管理器服务:

func initializeLocationManager() {
    // instance of location manager class
    var locationManager = CLLocationManager()
    locationManager.delegate = self // error here
    locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
    locationManager.requestAlwaysAuthorization()
    locationManager.startUpdatingLocation()
}

But on the 4th line of code, I get an error saying: 但是在第4行代码中,我收到一条错误消息:

Type 'AppDelegate' does not conform to protocol 'CLLocationManagerDelegate' 类型'AppDelegate'不符合协议'CLLocationManagerDelegate'

Why am I getting this error? 为什么我收到此错误? How do I fix this? 我该如何解决?

The error says: 错误说:

Type 'AppDelegate' does not conform to protocol 'CLLocationManagerDelegate' 类型'AppDelegate'不符合协议'CLLocationManagerDelegate'

So: 所以:

You are getting it because your class with the name AppDelegate does not conform to the protocol CLLocationManagerDelegate . 你得到它是因为你的名为AppDelegate类不符合协议CLLocationManagerDelegate

You can fix this by making that class conform to that protocol. 您可以通过使该类符合该协议来解决此问题。 So implement the methods that are required by the protocol, then declare that your class conforms to it. 因此,实现协议所需的方法,然后声明您的类符合它。

您必须在AppDelegate类中至少提供CLLocationManager.didUpdateLocations函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AppDelegate不符合Swift 3中的协议'GIDSignInDelegate' - AppDelegate does not conform to protocol 'GIDSignInDelegate' in Swift 3 在Xcode中看到为什么“类型不符合协议”(swift) - see why “type does not conform to protocol” in Xcode (swift) 类型不符合协议Swift - Type does not conform to protocol Swift Swift - 类型“*”不符合协议“*” - Swift - Type '*' does not conform to protocol '*' 'AppDelegate'不符合协议'GIDSignInDelegate' - 'AppDelegate' does not conform to protocol 'GIDSignInDelegate' 类型不符合协议序列类型 - Swift - type does not conform to protocol Sequence Type - Swift 类型“AppDelegate”不符合协议“WCSessionDelegate”调用无限次 - Type 'AppDelegate' does not conform to protocol 'WCSessionDelegate' calls infinity times Swift-类型'CircularTransition'不符合协议'UIViewControllerAnimatedTransitioning' - Swift - Type 'CircularTransition' does not conform to protocol 'UIViewControllerAnimatedTransitioning' Swift - MultipeerConnectivity类型不符合协议 - Swift - MultipeerConnectivity Type does not conform to protocol Swift-类型'MenuViewController'不符合协议'GKGameCenterControllerDelegate' - Swift - Type 'MenuViewController' does not conform to protocol 'GKGameCenterControllerDelegate'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM