CBCentralManager * EXC_BAD_ACCESS Manager with iOS7.0

I just updated the build success to Xcode V5.0 (5A1413), but running the program against the emulator causes an error when defining the property:

@property (non-atomic, strong) CBCentralManager * manager; → Topic 1: EXC_BAD_ACCESS (code = 2, address = 0x8)

+6
source share
1 answer

I ran into the same problem and finally turned to this:

UIDevice *currentDevice = [UIDevice currentDevice]; if ([currentDevice.model rangeOfString:@"Simulator"].location == NSNotFound) { self.centralMgr = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; } 

In the simulator, if I do not defend myself against creating a CBCentralManager, I see centralManagerDidUpdateState: called with CBCentralManager *, which corresponds to my strong property. It can be referenced, and the status is CBCentralManagerStateUnsupported. This makes sense, but if I'm in my strong control property at this point (since I'm not going to do BLE on a simulator that doesn't support it), I get EXC_BAD_ACCESS. Therefore, in the absence of a better answer, I suggest that you simply protect yourself from shooting at the manager in general, as in my code above.

+2
source

Source: https://habr.com/ru/post/954112/


All Articles