2014-09-26 89 views
1

我试图使用重大更改位置服务。我在OS Mavericks上使用Swift和XCode。我正试图增强一个iOS应用程序,这是我在教程之后构建的。类型'AppDelegate'不符合协议'CLLocationManagerDelegate' - Xcode 6中的Swift

在我AppDelegate.swift文件我已经创建了下面的方法来初始化我的位置管理服务:

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

但在代码的第4行,我得到一个错误说:

类型“ AppDelegate的”不符合协议‘CLLocationManagerDelegate’

为什么会出现这个错误?我该如何解决?任何帮助将不胜感激。

谢谢。

回答

2

错误说:

类型 '的AppDelegate' 不符合协议 'CLLocationManagerDelegate'

所以:

你得到它,因为与名称类AppDelegate呢不符合协议CLLocationManagerDelegate

您可以通过使该类符合该协议来解决此问题。所以实现协议所需的方法,然后声明你的类符合它。

1

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

相关问题