CoreBluetooth XPC连接在关闭viewcontroller时无效

Lou*_*257 16 objective-c ios core-bluetooth

在我完成与蓝牙设备的断开连接后,看到他们已经在didDisconnectPeripheral委托中断开连接,我试图解除我的viewcontroller.

当发生这种情况时,我看到消息:"[CoreBlueooth] XPC连接无效"

是否有特定的东西必须在视频控制器被解除之前用蓝牙清理?

oOE*_*ric 8

我放置CBCentralManager一个单身,错误信息解决了.

(CBCentralManager不会被解除分配)

  • 谢谢你。这帮助我解决了我的问题。您可以将 CBCentralManager 作为类变量(在函数外部声明)而不是局部变量。 (2认同)

Gab*_*oux 6

我收到以下消息:

[CoreBlueooth] XPC连接无效

而且我无法使用以下非常简单的实现来扫描BLE设备:

NSObject<CBCentralManagerDelegate, CBPeripheralDelegate>
Run Code Online (Sandbox Code Playgroud)

我的解决方案是在我Info.plist隐私 - 蓝牙外设使用说明中 添加一个值,NSBluetoothPeripheralUsageDescription描述我对蓝牙外设的处理方式.

看起来像这样info.plist:

<key>NSBluetoothPeripheralUsageDescription</key>
<string>Play with BLE Compatible devices<string>
Run Code Online (Sandbox Code Playgroud)

在这里写一些更准确的东西 ;)