本文转自:http://blog.csdn.net/feixiang_song/article/details/17395811
CBCentralManager objects are used to manage discovered or connected remote peripheral devices (represented by CBPeripheral objects), including scanning for, discovering, and connecting to advertising peripherals.
CBCentralManager 对象负责管理外设的发现或连接,包括扫描、发现、连接正在广播的外设。
Before you call CBCentralManager methods, the state of the central manager object must be powered on, as indicated by theCBCentralManagerStatePoweredOn constant. This state indicates that the central device (your iPhone or iPad, for instance) supports Bluetooth low energy and that Bluetooth is on and available to use.
CBCentralManager 方法前,我们必须查看中央管理器的状态是否为打开状态(CBCentralManagerStatePoweredOn)。如果是该状态,表明该中心设备(你的iphone或者ipad)是支持蓝牙低功耗4.0的。– initWithDelegate:queue:– initWithDelegate:queue:options:NSString *const CBCentralManagerOptionShowPowerAlertKey;用该参量出事中央管理器时,当蓝牙开关未打开时会弹出警告框。 NSString *const CBCentralManagerOptionRestoreIdentifierKey;该参量包含一个指定中央管理器的uid
– connectPeripheral:options:NSString *const CBConnectPeripheralOptionNotifyOnConnectionKey; NSString *const CBConnectPeripheralOptionNotifyOnDisconnectionKey; NSString *const CBConnectPeripheralOptionNotifyOnNotificationKey;讨论:当连接外设成功时要调用在委托对象中实现的方法:
centralManager:didConnectPeripheral:centralManager:didFailToConnectPeripheral:error:– cancelPeripheralConnection:– retrieveConnectedPeripheralsWithServices:– retrievePeripheralsWithIdentifiers:– retrieveConnectedPeripherals Deprecated in iOS 7.0centralManager:didRetrieveConnectedPeripherals:– retrievePeripherals: Deprecated in iOS 7.0– scanForPeripheralsWithServices:options:centralManager:didDiscoverPeripheral:advertisementData:RSSI: – stopScan 停止扫描state propertyWhen a central manager object is initially created, the default value of this property is CBCentralManagerStateUnknown.
当一个中央管理器对象初始化时,他的默认值是CBCentralManagerStateUnknown
As the central manager’s state changes, the central manager updates the value of this property and calls the centralManagerDidUpdateState:
当中央管理器状态改变时,会调用centralManagerDidUpdateState:委托方法
delegate property
Values representing the current state of a central manager object.
typedef enum {
CBCentralManagerStateUnknown = 0, 未知
CBCentralManagerStateResetting, 复位
CBCentralManagerStateUnsupported, 表明设备不支持蓝牙低功耗
CBCentralManagerStateUnauthorized,该应用程序是无权使用蓝牙低功耗。
CBCentralManagerStatePoweredOff, 关闭状态
CBCentralManagerStatePoweredOn, 打开状态
} CBCentralManagerState
Values representing the current state of a central manager object.
typedef enum {
CBCentralManagerStateUnknown = 0,
CBCentralManagerStateResetting,
CBCentralManagerStateUnsupported,
CBCentralManagerStateUnauthorized,
CBCentralManagerStatePowe
(转)CBCentralManager Class 的相关分析,布布扣,bubuko.com
(转)CBCentralManager Class 的相关分析
原文:http://www.cnblogs.com/kw-ios/p/3924529.html