我在project-Swift.h文件中得到一个名为'CBCentralManagerDelegate'的No类型或协议。不知道我在哪里错了。我认为它与swift.h有关,但是我是CoreBluetooth的新手,所以可能是
@objcMembers
class KestrelDeviceConnect: NSObject, CBCentralManagerDelegate, CBPeripheralManagerDelegate {
var manager:CBCentralManager!
var peripheral:CBPeripheral!
let serviceCBUUID = CBUUID(string: "0x181A")
var FieldSummaryModalLoaded = false
override init() {
super.init()
manager = CBCentralManager(delegate: self, queue: nil)
}
@objc func fieldSummaryReportMCLoaded(){
FieldSummaryModalLoaded = true
}
@objc func fieldSummaryReportMCChanged() {
FieldSummaryModalLoaded = false
}
func getWeatherReading() -> WeatherThirdPartyReadings {
var weatherReading = WeatherThirdPartyReadings(temperature: 0.00, speed: 0.00, direction: 0.00, observationTime: 0.00, isSummaryLoaded: false)
manager.scanForPeripherals(withServices: nil)
return weatherReading
}
func centralManagerDidUpdateState(_ central : CBCentralManager){
switch central.state {
case .poweredOff:
print("off")
case .poweredOn:
print("on")
manager.scanForPeripherals(withServices: [serviceCBUUID])
case .resetting:
print("resetting")
case .unauthorized:
print("unauthorized")
case .unknown:
print("unknown")
case .unsupported:
print("unsupported")
default:
break
}
}
func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
}
}
答案 0 :(得分:0)
在桥接标头中已达到#import <CoreBluetooth/CoreBluetooth.h>