我无法将值写入BLE设备。我翻译了这个:
NSLog(@"Writing value for characteristic %@", interestingCharacteristic);
[peripheral writeValue:dataToWrite forCharacteristic:interestingCharacteristic
type:CBCharacteristicWriteWithResponse];
到斯威夫特:
peripheral.writeValue("Writing value for characteristic", forCharacteristic: interestingCharacteristic, type: CBCharacteristicWriteWithResponse)
但我收到错误Use of unresolved identifier 'CBCharacteristicWriteWithResponse'
我是iOs编程的新手,并尝试了多种方法使其工作,但它不会发生。你能帮我吗?
答案 0 :(得分:1)
您已将NSLog
语句和writeValue
方法合并为某种奇怪的混搭。
你想要的是
println("Writing value for characteristic \(interestingCharacteristic)")
peripheral.writeValue(dataToWrite, forCharacteristic:interestingCharacteristic, type: CBCharacteristicWriteType.WithResponse)