简体   繁体   English

'NSInvalidArgumentException'/'-[AppDelegate fieldChanged:]:无法识别的选择器已发送到实例

[英]'NSInvalidArgumentException' / '-[AppDelegate fieldChanged:]: unrecognized selector sent to instance

The app terminates with a NSInvalidArgumentException when I use this code and I do not know why: 当我使用以下代码时,该应用程序以NSInvalidArgumentException终止,但我不知道为什么:

In my FieldViewController.m I have: 在我的FieldViewController.m我有:

-(IBAction)fieldEntered:(NSString*)sender {
[self.temp resignFirstResponder];
NSString *setFieldEntered;
setFieldEntered = temp.text;
fieldTemp = setFieldEntered;
[(EditViewController *)[[UIApplication sharedApplication] delegate] fieldChanged:(id)sender];

[self dismissModalViewControllerAnimated:YES]; 
}

It terminates on the [(EditViewController *)[[UIApplication sharedApplication] delegate] fieldChanged:(id)sender]; 它终止于[(EditViewController *)[[UIApplication sharedApplication] delegate] fieldChanged:(id)sender]; line. 线。

In my EditViewController.h I have -(void)fieldChanged:(id)sender; 在我的EditViewController.h中,我有-(void)fieldChanged:(id)sender; and in my EditViewController.m file I have: 在我的EditViewController.m文件中,我有:

-(void)fieldChanged:(id)sender {
    [fieldArray insertObject:[FieldViewController fieldEntered] atIndex:[fieldArray count]+1];
}

Please help me figure this one out. 请帮我弄清楚这一点。 Thank you. 谢谢。

从错误中可以看出,UIApplication的委托似乎设置为名为AppDelegate的类的实例,而您将其视为另一个名为EditViewController的类。

That doesn't make sense. 那没有道理。 May be you forgot to refer to the controller. 可能是您忘记了参考控制器。 Should be something like this: 应该是这样的:

[[[UIApplication sharedApplication] delegate].editViewController fieldChanged:sender];

暂无
暂无

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

相关问题 NSInvalidArgumentException || 无法识别的选择器已发送到实例 - NSInvalidArgumentException || Unrecognized selector sent to instance CoreData和NSInvalidArgumentException无法识别的选择器发送到实例 - CoreData and NSInvalidArgumentException unrecognized selector sent to instance AppDelegate setFullscreen:无法识别的选择器发送到实例 - AppDelegate setFullscreen: unrecognized selector sent to instance 异常'NSInvalidArgumentException',原因:'-[AnnotationView setCoordinate:]:无法识别的选择器已发送到实例 - exception 'NSInvalidArgumentException', reason: '-[AnnotationView setCoordinate:]: unrecognized selector sent to instance 'NSInvalidArgumentException':无法识别的选择器发送到实例0x8d25aa0' - 'NSInvalidArgumentException': unrecognized selector sent to instance 0x8d25aa0' 'NSInvalidArgumentException'-[UIViewController tableView:numberOfRowsInSection:]-无法识别的选择器已发送到实例 - 'NSInvalidArgumentException' - [UIViewController tableView:numberOfRowsInSection:] - unrecognized selector sent to instance NSInvalidArgumentException-无法识别的选择器已发送到实例 - NSInvalidArgumentException - Unrecognised Selector Sent to instance 无法识别的选择器发送到实例 - unrecognized selector sent to instance 无法识别的选择器已发送到实例? - Unrecognized selector sent to instance? 无法识别的选择器已发送到实例 - unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM