Corebluetooth 读取特性值变化
Corebluetooth changes in reading characteristics value
我目前正在将我的项目从 swift 2.3 迁移到 swift 3,但我对一件事感到困惑。在 swift 2.3 中我可以简单地使用
print("value \(characteristic.value!)")
并且它会打印我收到的值 61。但是在 swift 3 中它会打印类似 1 个字节的内容。为了获得我尝试使用命令
的值
print("value \(characteristic.properties.rawvalue)")
使用此命令,它 return 我的价值。但是苹果为什么要改变这个?
编辑
请问是不是bug?我正在使用 Xcode8.2.1 和 swift 3 命令
characteristic.value!
不会 return 我的价值。
characteristic.value
return 一个 Data
类型的值。这是我获取数据的方式。
if let dataBytes = characteristic.value {
if characteristic.uuid == CBUUID(string: "FFF1") {
print(dataBytes)
} else if characteristic.uuid == CBUUID(string: "FFF2") {
print(dataBytes)
}
}
我目前正在将我的项目从 swift 2.3 迁移到 swift 3,但我对一件事感到困惑。在 swift 2.3 中我可以简单地使用
print("value \(characteristic.value!)")
并且它会打印我收到的值 61。但是在 swift 3 中它会打印类似 1 个字节的内容。为了获得我尝试使用命令
的值print("value \(characteristic.properties.rawvalue)")
使用此命令,它 return 我的价值。但是苹果为什么要改变这个?
编辑
请问是不是bug?我正在使用 Xcode8.2.1 和 swift 3 命令
characteristic.value!
不会 return 我的价值。
characteristic.value
return 一个 Data
类型的值。这是我获取数据的方式。
if let dataBytes = characteristic.value {
if characteristic.uuid == CBUUID(string: "FFF1") {
print(dataBytes)
} else if characteristic.uuid == CBUUID(string: "FFF2") {
print(dataBytes)
}
}