我刚刚升级到Xcode V5.0(5A1413)构建成功但是对模拟器运行程序会导致属性定义出错:
@property(非原子,强)CBCentralManager*经理; - >线程1:EXC_BAD_ACCESS(代码= 2,地址= 0x8)
我遇到了同样的问题,最后求助于这个:
UIDevice *currentDevice = [UIDevice currentDevice];
if ([currentDevice.model rangeOfString:@"Simulator"].location == NSNotFound) {
self.centralMgr = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
Run Code Online (Sandbox Code Playgroud)
在模拟器上,如果我不防止创建 CBCentralManager,我会看到centralManagerDidUpdateState: 使用与我的强属性匹配的 CBCentralManager* 进行调用。可以引用,状态为CBCentralManagerStateUnsupported。这是有道理的,但如果我当时将我的强管理器属性归零(因为我不会在不支持它的模拟器上执行任何 BLE),我会得到 EXC_BAD_ACCESS。因此,在没有更好的答案的情况下,我建议您根本不要解雇经理,就像我上面的代码一样。
| 归档时间: |
|
| 查看次数: |
384 次 |
| 最近记录: |