下列...
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
print(characteristic)
}
..outputs ...
<CBCharacteristic: 0x1700b8180, UUID = FFE1, properties = 0x10, value = <01>, notifying = YES>
我想要“值”部分“01” .
3 回答
根据documentation,您可以通过调用:
characteristic.value
来访问它,这将是Data
类型的对象 . 然后,您可以将此对象转换为字符串 . 像这样:我要感谢OOPer在Apple Developer论坛上的回答 .
swift:在更新值时从特征中获取值 .