![](/img/trans.png)
[英]CBPeripheral setNotifyValue WithResponse do not call didWriteValueForCharacteristic
[英]CoreBluetooth : CBPeripheral has no member 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。 我不明白 我做了一些解決方法,但沒有得到任何幫助。
您正在使用Swift 3嗎? 方法簽名已更改為setNotifyValue(_:for:)
,即:
peripheral.setNotifyValue(true, for: characteristics[0])
您是否遷移到Swift 3? 新語法使用“ for”而不是“ forCharacteristic”:
peripheral.setNotifyValue(true, for: characteristics[0])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.