cocoa - 在一台用户 10.6.8 机器上崩溃,并将无法识别的选择器发送到类(class)

标签 cocoa macos xcode4 bluetooth osx-snow-leopard

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/

相关文章:

Cocoa 运行已包含双引号的 AppleScript

cocoa - 覆盖 NSDocument 窗口标题中的 "Edited"

excel - `Application.StatusBar` 是否在 Office 2011 中工作?

xcode4 - 如何让 AppCode 找到 Xcode 版本 4.3 (4E109) 的路径?

ios - Apple LLVM 编译器 3.1 - 警告 Objective-C++ 自动引用计数

c++ - Objective-C ID3 框架?

cocoa - 在 macOS 中观察系统日期/时间的变化

macos - 终端命令中的自动应答 "y"

ruby-on-rails - Rmagick 损坏 : Library not loaded:/usr/local/lib/libMagickCore-6. Q16.1.dylib

ios - 如何让 UIView 在 Interface Builder 中显示其导航 Controller 的导航栏