ios - CoreBluetooth 扫描特定服务

标签 ios swift core-bluetooth

我正在尝试搜索具有特定服务 UUID 的外围设备,我输入了如下代码行,但它弹出错误,我是不是漏掉了什么?有人可以建议吗。

centralManager.scanForPeripheralsWithServices([NSArray arrayWithObject [CBUUID UUIDWithString:@ "180A"]], options: nil)

最佳答案

我从你提供的信息中了解到的似乎是语法错误。
试试这段代码..

让 serviceUUIDs:[AnyObject] = [CBUUID(string: "180D")] centralManager.scanForPeripheralsWithServices(serviceUUIDs, options: nil)

关于ios - CoreBluetooth 扫描特定服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33473145/

相关文章:

ios - 获取权限后如何刷新权限

swift - 将 swift 属性的值绑定(bind)到 viewModel 的属性

iphone - CBCentralManager 的状态什么时候会打开但仍然给我一个 "not powered on"警告?

ios - iOS BLE 中心如何在通知模式下从外设接收超过 182 个字节?

ios - 遍历 TableViewCells 会跳过一些

android - 如何确保 UUID 对于我的 BLE 服务或特性是唯一的?

ios - 多线程核心数据 - permanentStoreCoordinator 与 ParentContext

iphone - 更改 UITable 部分标题颜色

ios - 如何在 SWIFTUI 主体内运行函数?

没有正确推断出 Swift 参数的类型?