简体   繁体   中英

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. I am attempting to enhance an iOS app that I built following a tutorial.

In my AppDelegate.swift file I have created the following method to initialise my location manager service:

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:

Type 'AppDelegate' does not conform to protocol 'CLLocationManagerDelegate'

Why am I getting this error? How do I fix this?

The error says:

Type 'AppDelegate' does not conform to protocol 'CLLocationManagerDelegate'

So:

You are getting it because your class with the name AppDelegate does not conform to the protocol 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函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM