加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Swift – BTLE – 如何添加CBCentralManagerDelegate Protocal

发布时间:2020-12-14 05:26:46 所属栏目:百科 来源:网络整理
导读:我想制作一个使用蓝牙进行通信的ios应用程序.我正在使用 swift. 所以首先我添加CoreBluetooth.framework,然后我添加一个bridge.h并将文件添加到系统桥,导入“CoreBluetooth / CoreBluetooth.h”. 然后我创建一个新类, import UIKitclass BTCentral: NSObject
我想制作一个使用蓝牙进行通信的ios应用程序.我正在使用 swift.

所以首先我添加CoreBluetooth.framework,然后我添加一个bridge.h并将文件添加到系统桥,导入“CoreBluetooth / CoreBluetooth.h”.

然后我创建一个新类,

import UIKit

class BTCentral: NSObject,CBCentralManagerDelegate   {

}

我打算在那个类中创建一个蓝牙CBCentralManager.但是,上面的代码给了我一个错误.

Type 'BTCentral' does not conform to protocol 'CBCentralManagerDelegate'

这是一个特定的ScreenShot:click here

任何帮助将不胜感激!非常感谢你们的时间.

您必须实现协议所需的所有方法.在这种情况下,CBCentralManagerDelegate只需要实现一个方法,centralManagerDidUpdateState().

将此方法添加到您的类中,错误将消失.

func centralManagerDidUpdateState(central: CBCentralManager!) {

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读