在框架提供的视图控制器上覆盖didSelectRowAtIndexPath?

时间:2015-10-29 22:01:40

标签: ios objective-c core-audio

所以我使用CoreAudioKit的CABTMIDICentralViewController来呈现MIDI蓝牙设备列表供用户选择。但是,我希望能够告诉用户在完成后选择了哪个设备,但似乎Apple没有添加任何方法来实现这一点。

所以我试图通过检测用户何时在表格中选择一行来破解它:

DPBleMidiDeviceManager.h:

#import <CoreAudioKit/CoreAudioKit.h>

@interface DPBleMidiDeviceManager : CABTMIDICentralViewController

@end

DPBleMidiDeviceManager.m:

#import "DPBleMidiDeviceManager.h"

@implementation DPBleMidiDeviceManager

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"midi device selected %@", indexPath);

    //either of these next lines crash, it makes no difference:
    //[[tableView delegate] tableView:tableView didDeselectRowAtIndexPath:indexPath];
    [super tableView:tableView didDeselectRowAtIndexPath:indexPath];
}
@end

问题是,它在最后一行崩溃,说没有选择器。这很奇怪,因为如果我删除超级调用,它不会崩溃,但它也没有正确连接到BLE设备,就像我没有覆盖该委托调用一样。

这只是Apple所做的事情,所以你无法访问他们的桌子吗?为什么他们会建立这样的UI视图并让你调用它,但是没有给你任何关于结果的信息?我错过了一些标准的方法吗?

编辑:这是super电话崩溃的详细信息:

2015-10-29 15:14:37.039 [626:338267] midi device selected <NSIndexPath: 0x1473ae20> {length = 2, path = 0 - 3}
2015-10-29 15:14:37.039 [626:338267] -[DPBleMidiDeviceManager tableView:didDeselectRowAtIndexPath:]: unrecognized selector sent to instance 0x147f34e0
2015-10-29 15:14:37.040 [626:338267] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DPBleMidiDeviceManager tableView:didDeselectRowAtIndexPath:]: unrecognized selector sent to instance 0x147f34e0'
*** First throw call stack:
(0x2b3cdfef 0x3967dc8b 0x2b3d3409 0x2b3d11bf 0x2b300e78 0xaa165 0x2eb3956b 0x2ebe843b 0x2ea9da91 0x2ea1838f 0x2b393fed 0x2b3916ab 0x2b391ab3 0x2b2de201 0x2b2de013 0x32aab201 0x2ea82a59 0x88447 0x39c09aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException

1 个答案:

答案 0 :(得分:1)

这不是你怎么称呼超级。它应该是

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"midi device selected %@", indexPath);

    [super tableView:tableView didDeselectRowAtIndexPath:indexPath];
}