2011-07-30 18:59:33.545 TokenLock[481:903] +[IOBluetoothDevice deviceWithAddress:]: unrecognized selector sent to class 0x7fff70c18cf8
2011-07-30 18:59:33.546 TokenLock[481:903] An uncaught exception was raised
2011-07-30 18:59:33.547 TokenLock[481:903] +[IOBluetoothDevice deviceWithAddress:]: unrecognized selector sent to class 0x7fff70c18cf8
2011-07-30 18:59:33.548 TokenLock[481:903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[IOBluetoothDevice deviceWithAddress:]: unrecognized selector sent to class 0x7fff70c18cf8'
实际代码:
BluetoothDeviceAddress addr;
IOBluetoothNSStringToDeviceAddress(selectedBTDeviceSerial, &addr);
actualBTDevice = [[IOBluetoothDevice alloc] init];
actualBTDevice = [IOBluetoothDevice deviceWithAddress:&addr];
关于如何排除故障或让他重新安装 IOBluetooth 系统的任何想法?
最佳答案
+[IOBluetoothDevice deviceWithAddress:]
是在 Mac OS X v10.7 SDK 中引入的。早期的 OS X 版本提供 +[IOBluetoothDevice withAddress:]
。您应该能够执行以下操作:
if ([[IOBluetoothDevice class] respondsToSelector:@selector(deviceWithAddress:)])
actualBTDevice = [IOBluetoothDevice deviceWithAddress:&addr];
else
actualBTDevice = [IOBluetoothDevice withAddress:&addr];
此外,您还泄漏了正在实例化的对象
actualBTDevice = [[IOBluetoothDevice alloc] init];
因为您立即将另一个对象分配给该变量。
关于cocoa - 在一台用户 10.6.8 机器上崩溃,并将无法识别的选择器发送到类(class),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6887062/