我已经选择了蓝牙设备,我正在尝试注册连接和断开通知
func selectDevice() {
var promptRes = Int32?((deviceSelector?.runModal())!)
if promptRes == Int32(kIOBluetoothUISuccess) {
self.selectedDevice = deviceSelector?.getResults().first as? IOBluetoothDevice
selectedDevice?
.register(forConnectNotifications: self, selector: #selector(connected))
selectedDevice?
.register(forDisconnectNotification: self, selector: #selector(disconnected))
self.connectDevice()
} else {
self.selectedDevice = nil
}
}
我没有问题,forDisconnectNotification
但我得到下一个错误forConnectNotifications
:
Incorrect argument label in call (have 'forConnectNotifications:selector:', expected 'forDisconnectNotification:selector:')
这太奇怪了,因为即使在官方文档中也记录了它forConnectNotifications
而不是forDisconnectNotification
.