objective-c - iPhone4S可以通过CoreBluetooth连接MBA吗?

标签 objective-c macos ios5 core-bluetooth

我正在尝试通过蓝牙在 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...
}

我的代码有什么问题?我错过了什么吗?

最佳答案

不,恐怕 CoreBluetooth 仅适用于低功耗设备( watch 、健康监视器等...) 使用此蓝牙配置文件无法将两个低功耗“主机”设备连接在一起。

关于objective-c - iPhone4S可以通过CoreBluetooth连接MBA吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8834816/

相关文章:

c - 如何在 Linux 和 Mac OSx 中获得更高级的网络接口(interface)卡类型

objective-c - 将 NSInteger 转换为 float ,反之亦然

iphone - 如何在 mfmailcomposerview 中关闭键盘

ios - UIView 动画立即发生

ios - 如何垂直放置UIStepper?

macos - Qt:如何为MAC定义Cmd+快捷键

objective-c - NSArray 的不区分大小写的 indexOfObject

objective-c - 使用 perl 与正在运行的 OS X 应用程序进行通信

objective-c - ios5 上的dismissViewControllerAnimated 崩溃

objective-c - 加载 View 之前,应用程序崩溃iOS> 6