Why do I get CBCentralManagerStateUnknown
on an iPad 2 when using this simple code?
- (BOOL)viewDidLoad {
bluetoothManager = [[CBCentralManager
I know why delegate is never called. Because the object is deleted from memory. Just make a strong property
@property (strong, nonatomic) DiscoverBluetoothDevices *btDevices;
And in init
@implementation DiscoverBluetoothDevices
- (id) init
{
self = [super init];
if(self) {
centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue()];
[centralManager scanForPeripheralsWithServices:nil options:@{CBCentralManagerScanOptionAllowDuplicatesKey: @YES}];
}
return self;
}
And now delegate is called properly.