草庐IT

coreBluetooth

全部标签

CoreBluetooth系列教程(二):蓝牙常用API

上篇讲了蓝牙相关的基本概念,现在结合代码讲讲具体实现。首先需要创建一个CBCentralManager对象,检查蓝牙的状态,只有蓝牙为poweredOn状态,才可进行下一步连接动作。CBCentralManager初始化先导入`CoreBluetooth`框架varcentralManager:CBCentralManager!//设置deleagte、queue、可选参数options,options可以为nil,也可设置CBCentralManagerOptionShowPowerAlertKey蓝牙提醒弹窗和CBCentralManagerOptionRestoreIdentifierK

CoreBluetooth系列教程(二):蓝牙常用API

上篇讲了蓝牙相关的基本概念,现在结合代码讲讲具体实现。首先需要创建一个CBCentralManager对象,检查蓝牙的状态,只有蓝牙为poweredOn状态,才可进行下一步连接动作。CBCentralManager初始化先导入`CoreBluetooth`框架varcentralManager:CBCentralManager!//设置deleagte、queue、可选参数options,options可以为nil,也可设置CBCentralManagerOptionShowPowerAlertKey蓝牙提醒弹窗和CBCentralManagerOptionRestoreIdentifierK