core-bluetooth

Setup bluetoooth central manager

Introduction#

CBCentralManager acts as a manager class central side app generally iOS app. which is responsible for bridging communication between peripherals and central.

Declare and instantiate CBCentralManager

Swift:

var centralManager:CBCentralManager!

centralManager = CBCentralManager(delegate: self, queue: nil)

Objective C:

@property (nonatomic, strong) CBCentralManager *centralManager;

centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

Declare and instantiate CBCentralManager with options

Swift:

var centralManager:CBCentralManager!

centralManager = CBCentralManager(delegate: self, queue: nil, options: [CBCentralManagerOptionRestoreIdentifierKey : "com.companyname.appname.central"])

Objective C:

@property (nonatomic, strong) CBCentralManager *centralManager;

self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:@{CBCentralManagerOptionRestoreIdentifierKey : @"com.companyname.appname.central"}];

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow