【发布时间】:2012-02-08 17:26:09
【问题描述】:
我正在尝试通过蓝牙在 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...
}
我的代码有什么问题?我错过了什么吗?
【问题讨论】:
标签: objective-c macos ios5 core-bluetooth