开发者

crashes on one users 10.6.8 machine with unrecognized selector sent to class

开发者 https://www.devze.com 2023-03-24 16:29 出处:网络
2011-07-30 18:59:33.545 TokenLock[481:903] +[IOBluetoothDevice deviceWithAddress:]: unrecognized selector sent to class 0x7fff70c18cf8
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'

Actual code:

BluetoothDeviceAddress addr;
IOBluetoothNSStringToDeviceAddress(selectedBTDeviceSerial, &addr);
actualBTDevice = [[IOBluetoothDevice alloc] init];
actualBTDevice = [IOBluetoothDevice deviceWithAddress:&addr];

Any ideas on how to troubleshoot, or have him reinstall the IOBluetooth system stuff?


+[IOBluetoothDevice deviceWithAddress:] was introduced in the Mac OS X v10.7 SDK. Earlier OS X versions provide +[IOBluetoothDevice withAddress:] instead. You should be able to do something like:

if ([[IOBluetoothDevice class] respondsToSelector:@selector(deviceWithAddress:)])
    actualBTDevice = [IOBluetoothDevice deviceWithAddress:&addr];
else
    actualBTDevice = [IOBluetoothDevice withAddress:&addr];

Also, you’re leaking the object you’re instantiating with

actualBTDevice = [[IOBluetoothDevice alloc] init];

since you’re immediately assigning another object to that variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消