我正在尝试通过蓝牙在 iOS 和 OSX 之间发送/接收数据。
因为 GameKit 不支持 OSX,所以我需要使用其他选项。iPhone4S和最新的Mac Book Air都支持蓝牙4.0,所以我认为这些设备之间建立连接是有可能的。
但是我下面的示例代码不起作用,需要您的帮助。虽然我只是创建了 CBCentralManager 并开始扫描设备(手头有两个 iPhone4S 和 MBA),但 - centralManager:didDiscoverPeripheral:advertisementData:RSSI: 从未被调用...
- (void)start {
self.mgr = [[[CBCentralManager alloc] initWithDelegate:self queue:nil] autorelease];
NSDictionary * opts = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
[self.mgr scanForPeripheralsWithServices:nil options:opts];
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
// not called this delegate method...
}
我的代码有什么问题?我错过了什么吗?