对于我正在处理的项目(使用 Swift,而不是 Object-C !!!)我需要将从 BLE 特征中提取的 UInt16 转换为字符串,以便可以将其用作标签的文本。有谁已经解决了这个问题?
提前感谢您的帮助。
var currentValue: UInt16!
func peripheral(peripheral: CBPeripheral!, didUpdateValueForCharacteristic characteristic: CBCharacteristic!, error: NSError!) {
if characteristic.UUID == xgatt_io_p_1 {
let data = characteristic.value
let reportData = UnsafePointer<UInt16>(data.bytes)
currentValue = reportData.memory
}
readValue()
}
label.text = convertedCurrentValue