ios - 位置管理器代理出现错误

标签 ios swift ibeacon

我正在尝试使用我从

获得的代码 https://github.com/Intermark/Buoy/tree/master/Buoy/Swift

我在 BUOYListener.swift 中收到以下错误,在此处输入代码BUOYBeacon.swift

知道如何解决这个问题吗?

enter image description here enter image description here

最佳答案

从 Swift 2.0 开始,Swift 编译器要求方法签名与您正在实现的协议(protocol)严格匹配。在这种情况下,这是 CLLocationManagerDelegate 和 CBPeripheralManagerDelegate。

didRangeBeacons 的正确 Swift 签名是:

func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion)

对于peripheralManagerDidUpdateState:

func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager)

最后,startAdvertising 需要一个 [String: AnyObject] 字典,但您要将 peripheralData 转换为 [NSObject:任何对象]。请改用以下转换:

self.beaconRegion.peripheralDataWithMeasuredPower(nil) as! [String: AnyObject]

关于ios - 位置管理器代理出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34983684/

相关文章:

swift - ios8 swift : how can i access/edit/remove default/private inputAccessoryView height constraint '_UIKBAutolayoutHeightConstraint'

ios - Healthkit 多个 HKAnchoredObjectQuery 未返回所有样本类型的数据

ios - iBeacons 发送和接收 UUID

ios - Eddystone 信标检测问题

ios - react-native 应用程序在分发时崩溃

ios - 如何知道我的应用程序何时聚焦或不聚焦 - react 原生?

iphone - Xcode 使用 textField shouldChangeCharactersInRange : crashes app

android - Paypal 手机SDK : Authorize a token returned from SetExpressCheckout method

objective-c - swift 扩展 "Method definition not found"

linux - 用于扫描 iBeacon 并在 Raspberry Pi 上使用 GPIO 的 Bash 脚本