如何解决:无法识别的选择器已发送到实例 [英] How to fix: unrecognized selector sent to instance

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

问题描述

我遇到的问题可能很容易解决,但对我来说调试起来并不简单.我简单地在IB的视图中有一个按钮;文件的所有者设置为我正在使用的视图控制器类,并且在进行连接时,一切似乎都很好,即.连接器正在找到我要调用的方法等.

I am having a problem that may be simple to fix, but not simple for me to debug. I simple have a button inside a view in IB; the file's owner is set to the view controller class I am using and when making the connections, everything seems fine, ie. the connector is finding the method I am trying to call etc.

但是,我收到此错误:由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'***-[UIApplication getStarted:]:无法识别的选择器已发送至实例0x3d19130'

however, I am receiving this error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIApplication getStarted:]: unrecognized selector sent to instance 0x3d19130'

我的代码如下:

RootViewController.h

RootViewController.h

@interface RootViewController : UIViewController {
IBOutlet UIButton* getStartedButton;
}

@property (nonatomic, retain) UIButton* getStartedButton;

- (IBAction) getStarted: (id)sender;

@end

RootViewController.m

RootViewController.m

#import "RootViewController.h"
#import "SimpleDrillDownAppDelegate.h"


@implementation RootViewController

@synthesize  getStartedButton;

- (void)viewDidLoad {
    [super viewDidLoad];
}


- (IBAction) getStarted: (id)sender {
    NSLog(@"Button Tapped!");
    //[self.view removeFromSuperview];  
}

- (void)dealloc {
    [getStartedButton release];
    [super dealloc];
}

@end

似乎很简单...有什么可意的吗?

Seems simple enough...any thoughs?

推荐答案

在将RootViewController添加到窗口后,您似乎已经释放了它.

It looks like you have released the RootViewController after add it to your window.

在此处发布将RootViewController添加到窗口的代码.

Post here the piece of code where you add RootViewController to your window.

顺便说一句,尝试在发布的行中添加注释.因此,代替使用:

BTW, try to comment the line where you do the release. So, instead of use:


RootViewController *viewController = [[RootViewController alloc] init];
[window addSubview:viewController.view];
[viewController release];

这样做:


RootViewController *viewController = [[RootViewController alloc] init];
[window addSubview:viewController.view];
//[viewController release];

之后,您的方法"getStarted"应该可以使用.

Your method "getStarted" should work after that.

干杯,VFN

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

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