gpt4 book ai didi

swift ,核心蓝牙 : services and characteristics

转载 作者:行者123 更新时间:2023-11-28 13:12:38 25 4
gpt4 key购买 nike

peripheral didDiscoverServices()peripheral didDiscoverCharacteristicsForService() 中,我正在尝试以下操作:

for service in peripheral.servicesfor characteristic in service.characteristics,只收到(对于这两个调用)这个错误:

'[CBService]?' does not have a member named 'Generator'

'[CBCharacteristic]?' does not have a member named 'Generator'

如何解决这两个错误?

最佳答案

这是一个问题,因为在 Swift 中,peripheral.servicesservice.characteristics 是可选属性。编译器告诉你它们可以是 Nil,所以你不能这样做。不幸的是,您看到的错误消息非常含糊,因此您必须进行 Google 搜索才能弄清楚它的含义。

试试这个:for service in peripheral.services ?? []

关于 swift ,核心蓝牙 : services and characteristics,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30767438/

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