简体   繁体   English

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

[英]unrecognized selector sent to instance

My app works fine in the simulator but when I run it on my phone I get this error: 我的应用程序在模拟器中运行良好,但是当我在手机上运行该应用程序时,出现此错误:

2010-04-05 21:32:45.119 Top Banana[119:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[MethodViewController setReferringObject:]: unrecognized selector sent to instance 0x16e930' 2010-04-05 21:32:45.119 Top Banana [119:207] *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'* -[MethodViewController setReferringObject:]:无法识别的选择器已发送至实例0x16e930'

It happens here: 它发生在这里:

-(void)method {

 [UIView beginAnimations:@"View Flip" context:nil];
 [UIView setAnimationDuration:0.50];
 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

 [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
 MethodViewController *methodViewController = [[MethodViewController alloc] initWithNibName:@"MethodViewController" bundle:0];   

 NSManagedObject *selectedObject = self.referringObject;
 methodViewController.referringObject = selectedObject;

 [self.navigationController pushViewController:methodViewController animated:NO];

 methodViewController.title = @"Method";

 [UIView commitAnimations];

 [MethodViewController release]; 
}

It crashes on this line: 它在此行崩溃:

methodViewController.referringObject = selectedObject;

Not sure how to resolve this as it works in the simulator, I'm sure it is fairly basic to fix, any help will be appreciated. 不确定如何解决此问题,因为它可以在模拟器中正常工作,但我敢肯定它是非常基本的修复程序,我们将不胜感激。

Not sure why it's happening, but this test could yield some helpful diagnostic information: Set a breakpoint on the line that's crashing, and Build and Debug on your phone. 不确定为什么会发生这种情况,但是此测试可能会产生一些有用的诊断信息:在崩溃的线路上设置断点,并在手机上进行Build and Debug。 Then type "po methodViewController" at your gdb prompt to find out what kind of object that variable actually points to at runtime. 然后在您的gdb提示符下键入“ po methodViewController”,以找出变量在运行时实际指向的对象类型。 Then try the same thing in the simulator and compare. 然后在模拟器中尝试相同的操作并进行比较。 You're probably getting an object of the wrong class on the phone for some reason. 由于某种原因,您可能会在电话上收到错误类别的对象。 Knowing its actual class will probably help. 了解其实际类别可能会有所帮助。

Grasping at straws, but here are some other things to check: 抓稻草,但是这里还有其他一些检查要点:

  1. Make sure MethodViewController.xib is in your project and included in your target's "Copy Bundle Resources" phase. 确保MethodViewController.xib位于您的项目中,并且包含在目标的“复制捆绑资源”阶段。 Sometimes the simulator manages to magically find resources on your filesystem that haven't been properly included in your project. 有时,模拟器设法神奇地在文件系统中查找未正确包含在项目中的资源。

  2. Make sure you don't have an old copy of MethodViewController.xib sitting around in some other directory under your project. 确保您的项目下其他目录中没有旧的MethodViewController.xib副本。

  3. Make sure your File's Owner in MethodViewController.xib is set to MethodViewController. 确保在MethodViewController.xib中将文件的所有者设置为MethodViewController。

  4. Try Build -> Clean All Targets. 尝试构建->清理所有目标。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM