我希望在值发生变化时收到通知.我正在学习本教程 - > 核心蓝牙简介:构建心率监测器
我用这个蓝牙设备 - > IC卡读卡器(索尼产品)
- (void)viewDidLoad {
[super viewDidLoad];
_myCentralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[_myCentralManager scanForPeripheralsWithServices:nil options:nil];
self.myCentralManager = _myCentralManager;
}
#pragma mark - CBCentralManagerDelegate
// method called whenever you have successfully connected to the BLE peripheral
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral
{
[peripheral setDelegate:self];
[peripheral discoverServices:nil];
NSString *connected = [NSString stringWithFormat:@"Connected: %@", peripheral.state == CBPeripheralStateConnected ? @"YES" : @"NO"];
NSLog(@"%@", connected);
}
// CBCentralManagerDelegate - This is called with the CBPeripheral class as its …Run Code Online (Sandbox Code Playgroud)