我使用 IOBluetoothDeviceSelector 选择了一个 IOBluetoothDevice。之后,我用设备做一些事情;没关系。
当设备足够接近时,是否可以保存 IOBluetoothDevice 并自动连接? (也重新启动应用程序后)
谢谢!
最佳答案
IOBluetoothDevice
有以下方法对您有用:- [IOBluetoothDevice addressString]
它将为您提供设备地址作为字符串,您可以轻松地存储在您的应用程序默认值中。+ [IOBluetoothDevice deviceWithAddressString:(NSString*) address]
将允许您构建一个 IOBluetoothDevice*
在应用程序重新启动后使用该地址字符串。- [IOBluetoothDevice openConnection]
或 - [IOBluetoothDevice openConnection:(id)delegate]
这将允许您以同步或异步方式打开与您创建的设备的连接。
关于macos - Mac : auto connect to IOBluetoothDevice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9502056/