我正在研究 CoreBluetooth 框架。我运行了著名的temperatureSensor
应用程序,但是当我在模拟器上运行它时,我收到以下警告:
CoreBluetooth[WARNING] <CBConcreteCentralManager: 0x713b550> is not powered on
我检查了CBCentralManager
它的状态Unknown
。以下是代码:
(void) startScanningForUUIDString:(NSString *)uuidString {
centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
if ([centralManager state] == CBCentralManagerStatePoweredOff) NSLog(@"CBCentralManagerStatePoweredOff");
if ([centralManager state] == CBCentralManagerStatePoweredOn) NSLog(@"CBCentralManagerStatePoweredOn");
if ([centralManager state] == CBCentralManagerStateResetting) NSLog(@"CBCentralManagerStateResetting");
if ([centralManager state] == CBCentralManagerStateUnauthorized) NSLog(@"CBCentralManagerStateUnauthorized");
if ([centralManager state] == CBCentralManagerStateUnknown) NSLog(@"CBCentralManagerStateUnknown");
if ([centralManager state] == CBCentralManagerStateUnsupported) NSLog(@"CBCentralManagerStateUnsupported");
NSArray *uuidArray = [NSArray arrayWithObjects:[CBUUID UUIDWithString:uuidString], nil];
NSLog(@"%@", uuidArray);
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
[centralManager scanForPeripheralsWithServices:uuidArray options:options];
}
我该如何解决?