Objective-C警告:类'ViewController'不符合协议'CBPeripheralManagerDelegate'

问题描述

我正在尝试创建Obj-C,CoreBluetooth虚拟外设应用程序并收到此警告。

.Name

解决方法

您需要实现必需的CBPeripheralManagerDelegate协议方法:

peripheralManagerDidUpdateState:

如此处文档所述:https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate?language=objc

协议必需的一种方法,peripheralManagerDidUpdateState :,只要外围设备管理器的状态更新以指示外围设备管理器是否可用,Core Bluetooth就会调用该方法。

,

您可以查看此存储库中如何设置CoreBluetooth的Objective-C示例:

https://github.com/LGBluetooth/LGBluetooth

回到当我仍然在ObjC中编码时,它是我使用的库-很棒。

至少,它将为您提供有关如何实现接口的一些想法。

这是一个听起来像您想做的事的Swift实现(基于几天前提出的另一个问题)。也许您可以将其反向移植到ObjC(免责声明:我是作者)。

https://github.com/RobotPajamas/SwiftyTeeth/blob/master/Sources/SwiftyTooth/SwiftyTooth.swift