如何调试“无法识别的选择器发送到实例”问题? [英] How do I debug an 'unrecognized selector sent to instance' problem?

查看:102
本文介绍了如何调试“无法识别的选择器发送到实例”问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在视图控制器中有以下代码(在所有其他方面)似乎工作正常:

I have the following code in a view controller that (in all other respects) seems to be working fine:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    ProblemViewController *problemViewController = [[ProblemViewController alloc] initWithNibName:@"ProblemViewController" bundle:nil];
    problemViewController.problem = (Problem*)[self.problems objectAtIndex:indexPath.row];
    [self.navigationController pushViewController:problemViewController];
    [problemViewController release];
}

但是,当我运行此函数时,我收到以下错误:

When I run through this function, however, I am getting the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[ProblemViewController initWithNibName:bundle:]: unrecognized selector sent to instance 0x57ca80'

我不知道可能导致什么它,所以我的问题是:我应该如何最好地调试这个问题?有什么明显我应该检查吗?

I'm at a loss as to what could be causing it, so my question is: How should I best go about debugging this problem? Is there anything obvious I should be checking?

推荐答案

检查ProblemViewController的基类。我打赌你不是从UIViewController继承的,它包含 initWithNibName:bundle:方法。

Check the base class for ProblemViewController. I'm betting you're not inheriting from UIViewController, which includes the initWithNibName:bundle: method.

这篇关于如何调试“无法识别的选择器发送到实例”问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆