我正在尝试实现一个BLEHandler。
这是我的代码:
import CoreBluetooth
class BLEHandler : NSObject, CBCentralManagerDelegate {
override init() {
super.init()
}
func cenrealManagerDidUpdateState(central: CBCentralManager!)
{
switch (central.state)
{
case . unsupported:
print("BLE is unsupported")
case.unauthorized:
print("BLE is unauthorised")
case.unknown:
print("BLE is unknown")
case.resetting:
print("BLE is resetting")
case.poweredOff:
print("BLE is powered off")
case.poweredOn:
print("BLE is powered on")
default:
print("BLE default")
}
}
}我得到一个错误:“类型'BLEHandler‘不符合协议'CBCentralManagerDelegate'”
我有'centralManagerDidUpdateState‘方法,所以我不知道我错过了什么,等等。
发布于 2017-03-02 20:02:26
方法名称拼写错误。不是cenrealManagerDidUpdateState,应该是centralManagerDidUpdateState
试着...
func centralManagerDidUpdateState(_ central: CBCentralManager)
{
}https://stackoverflow.com/questions/42554081
复制相似问题