1

当我使用以下方法禁用重复键过滤时:

NSDictionary *options    = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];

构建和运行工作正常(并捕获所有广告数据包),但它总是首先产生此错误:

“CoreBluetooth[WARNING] 正在禁用重复过滤,但使用默认队列(主线程)处理委托事件”

如果我添加,我可以停止显示警告:

dispatch_queue_t centralQueue = dispatch_queue_create("central", DISPATCH_QUEUE_SERIAL);

在我创建 CBCentralManager 实例并将队列参数设置为 centralQueue 之前。这是解决此问题的正确方法吗?或者,还有更好的方法?

谢谢

4

1 回答 1

2

就这样有一个正确的答案:

如果将 CBCentralManager 设置为在主队列上运行,则将扫描选项设置为允许重复可能会降低整体性能。如果您需要允许重复,最好在单独的队列上运行 CBCentralManager。

dispatch_queue_t centralQueue = dispatch_queue_create("mycentralqueue", DISPATCH_QUEUE_SERIAL);
_centralManager = [[CBCentralManager alloc]initWithDelegate:self queue:centralQueue];
于 2014-05-07T15:15:11.957 回答