【问题标题】:CoreBluetooth - Disabling duplicate key filter causes warningCoreBluetooth - 禁用重复密钥过滤器会导致警告
【发布时间】:2014-01-06 19:56:51
【问题描述】:

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

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

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

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

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

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

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

谢谢

【问题讨论】:

  • 没有更好的办法。你做对了。
  • 我认为你做得对。 iOS 创建一个警告,因为忽略重复键可能需要更多时间/CPU 或类似的东西。

标签: queue core-bluetooth cbcentralmanager


【解决方案1】:

只要有一个正确的答案:

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

dispatch_queue_t centralQueue = dispatch_queue_create("mycentralqueue", DISPATCH_QUEUE_SERIAL);
_centralManager = [[CBCentralManager alloc]initWithDelegate:self queue:centralQueue];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-21
    • 2012-12-27
    • 1970-01-01
    • 2018-03-28
    • 1970-01-01
    • 1970-01-01
    • 2020-09-01
    • 2019-03-24
    相关资源
    最近更新 更多