gpt4 book ai didi

ios - Corebluetooth 读取特性值变化

转载 作者:行者123 更新时间:2023-11-28 15:57:09 25 4
gpt4 key购买 nike

我目前正在将我的项目从 swift 2.3 迁移到 swift 3,我对一件事感到困惑。在 swift 2.3 中,我可以简单地使用

 print("value \(characteristic.value!)")

它会打印我收到的值 61。但是在 swift 3 中它会打印 1 个字节。为了获得我尝试使用命令的值

print("value \(characteristic.properties.rawvalue)")

使用此命令,它会返回值。但苹果为什么要改变这一点?

编辑

不知道是不是bug?我正在使用 Xcode8.2.1 和 swift 3 命令

characteristic.value!

不会返回值。

最佳答案

characteristic.value 返回一个Data 类型的值。这是我获取数据的方式。

        if let dataBytes = characteristic.value {
if characteristic.uuid == CBUUID(string: "FFF1") {
print(dataBytes)
} else if characteristic.uuid == CBUUID(string: "FFF2") {
print(dataBytes)
}
}

关于ios - Corebluetooth 读取特性值变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41540992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com