ios - 如何删除/取消订阅核心蓝牙服务?

标签 ios swift core-bluetooth

我尝试通过以下方式实现它:

peripheral.services?.removeAll()

但它返回错误

cannot use mutating member on immutable value

删除或取消订阅服务的正确方法是什么?

最佳答案

错误明确指出peripheral.services?不是不可变的内容。因此您无法编辑其中的内容。

您需要使用

removeAllServices() - 删除所有已发布的服务

remove(CBMutableService) - 删除指定的服务

苹果引用

Core bluetooth Reference

关于ios - 如何删除/取消订阅核心蓝牙服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40236089/

相关文章:

iphone - iPhone 版 Xcode facebook 连接

swift - 将 Swift 2.3 转换为 Swift 3.0 - 错误,无法使用类型为'的参数列表调用 'dataTask'

ios7 - 后台 iBeacon - 用例

swift - 节点在场景中的位置

swift - 带渐变和阴影的 UIView

ios - 如何存储 CBPeripheral 以在其他 View 中使用

ios - Objective C 中的蓝牙配对与连接

ios - 有没有办法在不使用设置页面的情况下通过我的 iOS 应用程序连接 Wi-Fi 调制解调器?

ios - 检测 iOS 8 Quicktype 建议粘贴

ios - 动态 tableViewCell 高度