无法识别的选择器发送到实例(iOS)

问题描述:


可能重复:

无法识别的选择器发送到实例

嗯...喜欢这么多其他人,我得到了一个无法识别的选择器发送到实例错误...

Well... like so many others, I have gotten a "unrecognized selector sent to instance" error...

当我按下按钮时出现问题,例如在这种情况下:

The problem occurs when I press a button, e.g. in this case:

-(IBAction)gotoTone:(id)sender
{
    if(self.tone == nil)
    {
       Tone *toneMain = [[Tone alloc]
                              initWithNibName:@"Tone" bundle:[NSBundle mainBundle]];
       self.tone = toneMain;
       [toneMain release];
    }

    [self.navigationController pushViewController:tone animated:YES];
}

错误是:由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因: ' - [Tone gotoTone:]:无法识别的选择器发送到实例0x531caa0'

The error is: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Tone gotoTone:]: unrecognized selector sent to instance 0x531caa0'

在我插入新视图作为向用户显示的第一个视图后,错误开始发生。另外,我使用导航栏,起初我忘记进入MainWindow.xib并将导航控制器更改为新视图,但现在已修复。

The error started occurring after I inserted a new view as the first view presented to the user... Also, I use a navigation bar and at first I had forgotten to go into MainWindow.xib and change the Navigation Controller to the new view, but that is fixed now.

你可以看到我的整个代码:

You can see my entire code her:

文件出现的.h: http://snipt.org/xnoO
文件出现的.m: http://snipt.org/xnoM

不要介意所有评论过的行,直到我解决这个问题。 ..

Don't mind all the out-commented lines, that's just until I get this fixed...

我试过通过阅读无法识别的sele的其他案例来寻找解决方案ctor发送到实例,但我想我只是没有看到解决方案。我已经检查了我的IB连接,我已经清理了项目等...

I've tried finding a solution to this by reading other cases of "unrecognized selector sent to instance", but I guess I'm just not seeing the solution. I've checked my IB-connects, I've cleaned the project and such...

任何帮助将不胜感激

我遇到了这个问题并通过将Button重新连接到之前修改过其名称的IBAction来解决了这个问题。太尴尬了。

I met this issue and solved it just by reconnected the Button to the IBAction whose name was modified before. So embarrassing.