简体   繁体   English

为什么在我的应用程序中看到以下异常?

[英]Why am I seeing the following exception within my application?

I'm creating an iPhone application. 我正在创建一个iPhone应用程序。 I have two view controllers (the main one and an about window). 我有两个视图控制器(主要的一个和一个关于窗口)。 In the about view controller i have a UIButton which is linking to a IBAction in the view controller. 在About视图控制器中,我有一个UIButton,它链接到视图控制器中的IBAction。

I'm getting: 我越来越:

2010-08-05 21:40:05.741 appname[9151:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[aboutViewController gotoMain2]: unrecognized selector sent to instance 0x5c09950'

Heres the code: 这是代码:

//
//  aboutAboutViewController.h
//
//  Created by **** on 5/08/10.
//  Copyright 2010 ***. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface AboutViewController : UIViewController {

}
- (IBAction)gotoMain2;
@end

And the .m file:

//
//  AboutViewController.m
//
//  Created by **** on 5/08/10.
//  Copyright 2010 ****. All rights reserved.
//

#import "AboutViewController.h"

@implementation AboutViewController
- (IBAction)gotoMain2 { 
 [self dismissModalViewControllerAnimated:TRUE];
}
@end

I'm 100% sure that everything is linked up correctly in xCode and Interface Builder 我100%确保在xCode和Interface Builder中所有内容都正确链接

Any help is greatly appreciated 任何帮助是极大的赞赏

Thanks. 谢谢。 Daniel 丹尼尔

UPDATE: I found out just now that its trying to point to a different class.. But its correct in IB??? 更新:我刚刚发现它试图指向一个不同的类。但是在IB中它是正确的???

You should check where you actually create this instance of AboutViewController. 您应该检查在哪里实际创建AboutViewController实例。 Setting the class for "File's Owner" just tells IB what class to expect . 设置“文件所有者”的类只是告诉IB 期望什么类。 But it may be that the actual object loading this nib is not an AboutViewController. 但是可能加载此笔尖的实际对象不是AboutViewController。

BTW, "editing" error messages to hide some secret is a good way to obscure the actual bug and make it harder for other people to help. 顺便说一句,“编辑”错误消息以隐藏一些秘密是掩盖实际错误并使其他人更难以帮助的好方法。 :) :)

The error message says aboutViewController , but in your code it is named AboutViewController . 该错误消息显示aboutViewController ,但是在您的代码中它名为AboutViewController Make sure the case matches, also in the Interface Builder properties. 确保大小写匹配,同样在Interface Builder属性中。

If you have it setup correctly then its a "Thing Inside(TM)". 如果安装正确,则为“ Thing Inside(TM)”。

Delete the button. 删除按钮。 Create a new one and set it up again. 创建一个新的,然后重新设置。

Make sure to exit and reload in Interface Builder. 确保退出并在Interface Builder中重新加载。

Try: 尝试:

- (IBAction)goToMain2:(id)sender;

and

- (IBAction)goToMain2:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}

Clearly you haven't linked it up correctly, or you would not be getting the exception. 显然,您没有将其正确链接,否则您将不会获得异常。

I wouldn't mind betting that the error message looks more like this: 我不介意打赌错误消息看起来更像这样:

-[AboutViewController gotoMain2:]: unrecognized selector sent to instance 0x5c09950
                               ^^ colon here

The reason I think that is that IBAction s are usually declared thus: 我认为的原因是通常这样声明IBAction

-(IBAction) doAnAction: (id) sender;
                      ^^^^^^^^^^^^^ actions take a parameter which is the object that sends them..

If that's not the problem, you need to run the application in the debugger with break on exception set. 如果这不是问题,则需要在调试器中运行带有异常中断的应用程序。 You can then check if the object to which the action is being sent really is what you think it is. 然后,您可以检查将动作发送到的对象是否确实是您认为的样子。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在OS 3.1上的应用程序中看不到加载屏幕,但在4.0上却显示? - Why am I not seeing a loading screen in my application on OS 3.1, but I am on 4.0? 在使用Core Plot构建iPhone应用程序时,为什么会看到以下链接器错误? - Why am I seeing the following linker errors when building an iPhone app with Core Plot? 为什么我在生产应用程序中看到iAd的广告,就像我在开发中所做的那样? - Why am I seeing iAd's advertisements, like I did in development, in my production app? 为什么会看到“此应用程序不支持该设备的CPU类型”? - Why am I seeing “This application does not support this device's CPU type”? 为什么会看到以下警告:“假定没有匹配方法签名的消息将返回&#39;id&#39;并接受&#39;...&#39;作为参数”? - Why am I seeing the following warning: “Messages without a matching method signature wii be assumed to return 'id' and accept'…'as arguments ”? 为什么会看到错误“格式不是字符串文字且没有格式参数”? - Why am I seeing the error “Format is not a string literal and no format arguments”? 为什么我看到有关NSAutoreleasePool不可用的消息警告? - Why am I seeing a message warning about NSAutoreleasePool being unavailable? 为什么在显示此表视图时看到崩溃? - Why am I seeing a crash when displaying this table view? 为什么会出现NSInvalidArgument异常? - Why am I getting NSInvalidArgument Exception? 为什么我看到有关核心情节的_OBJC_CLASS _ $ _ CPGraphHostingView的错误? - Why am I seeing an error about _OBJC_CLASS_$_CPGraphHostingView with Core Plot?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM