【发布时间】:2012-07-17 02:38:39
【问题描述】:
我看到在 iOS 5 中,CoreBluetooth 提供了检查蓝牙是否被禁用的功能。从我看到的文档来看,它显然是针对蓝牙外设使用的。但是,我正在尝试检查蓝牙是否已打开,因为我正在使用 GameKit (GKPeerPickerController),如果未启用,它将无休止地搜索蓝牙连接,这是一个问题。
我试着这样做:
CBCentralManager * manager = [[CBCentralManager alloc] init];
if (manager.state == CBCentralManagerStatePoweredOn ) {
//go ahead with GameKit
}
这不起作用,manager.state 始终等于 null。我在这里做错了什么?或者,有没有更好的方法来检查 iPhone 上的蓝牙状态?
编辑:我不想调用任何私有 API,因为我将把这个应用程序提交到应用商店。我已经编辑了我的问题标题以澄清这一点。
【问题讨论】:
标签: iphone ios cocoa-touch gamekit core-bluetooth