OSX不赞成使用蓝牙功能

时间:2014-03-31 14:50:33

标签: macos bluetooth iobluetooth

我正在关注"蓝牙设备访问指南"在Mac Developer库中,关于如何实现Mac RFCOMM服务器。在有关如何将服务定义添加到SDP数据库的指南中,有一个代码清单使用了不推荐使用的函数:

// Now that we have an IOBluetoothSDPServiceRecord object,
// we no longer need the IOBluetoothSDPServiceRecordRef.
IOBluetoothObjectRelease( serviceRecordRef );

Apple documentation

在谷歌搜索这个功能时,我发现了几个仍然使用该功能的开源项目。我还发现了一些更改日志,说已删除此功能,我找到了一些标题文档,说明了以下内容:

The ref counting scheme allows the IOBluetoothObjectRefs to be freed 
when they are no longer used. When the ref count reaches zero, 
the target object will be freed.

***      DEPRECATED IN BLUETOOTH 2.2 (Mac OS X 10.6) ***      
You should transition your code to Objective-C equivalents. ***      
This API may be removed any time in the future.

基于此,我的问题是:

  • 为什么Mac文档使用不推荐使用的功能?
  • 什么是Objective-C等价物?

1 个答案:

答案 0 :(得分:2)

显然是:

IOBluetoothAddServiceDict

函数也已被弃用(但仍然可用)。相反,我应该使用

+[IOBluetoothSDPServiceRecord publishedServiceRecordWithDictionary:]

似乎不需要使用释放功能。