我正在一個應用程序中,我需要與外部設備建立藍牙連接,並且我成功地與外部設備建立了連接。現在CoreBluetooth:CBPeripheral沒有成員setnotifyValue iOS 10.0
,在下面CBPeripheralManager代表在iOS的10產生誤差和iOS的工作完美9.0
func peripheral(peripheral: CBPeripheral, didDiscoverCharacteristicsForService service: CBService, error: NSError?) {
if serviceCharacteristics.keys.contains(service.UUID) {
guard let characteristics = service.characteristics else { return }
peripheral.setNotifyValue(true, forCharacteristic: characteristics[0])
}
,我在下面的行收到錯誤,
peripheral.setNotifyValue(true, forCharacteristic: characteristics[0])
它說,CBPeripheral沒有成員setNotifyValue。我不明白。我做了一些解決方法,但沒有得到任何幫助。
不錯。更快的抽籤。 ;) – davidethell
你看到我們的答案有多相似嗎?我們必須有類似的線頭腦。 –
早些時候,我在swift 2.3中做了代碼,現在當我更改部署目標並嘗試運行我的應用程序時,出現以上錯誤。我在委託方法做下面的代碼,如果#available(iOS的10.0,*){ peripheral.setNotifyValue(真,爲:特性[0]) } 否則{ peripheral.setNotifyValue(啓用:真,特性:特性[0 ]) } –