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

时间:2010-04-05 20:46:29

标签: iphone

我的应用程序在模拟器中工作正常但是当我在手机上运行时出现此错误:

  

2010-04-05 21:32:45.119 Top   香蕉[119:207] *终止应用程序   由于未被捕获的例外   'NSInvalidArgumentException',原因:   '* - [MethodViewController   setReferringObject:]:无法识别   选择器发送到实例0x16e930'

它发生在这里:

-(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]; 
}

它在这一行崩溃了:

methodViewController.referringObject = selectedObject;

不确定如何在模拟器中解决这个问题,我确信它是相当基本的修复,任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

不确定为什么会发生这种情况,但是这个测试可能会产生一些有用的诊断信息:在崩溃的线路上设置一个断点,在手机上设置Build and Debug。然后在gdb提示符下键入“po methodViewController”,以找出变量在运行时实际指向的对象类型。然后在模拟器中尝试相同的事情并进行比较。出于某种原因,你可能会在手机上找到错误课程的对象。知道它的实际课程可能会有所帮助。

抓住吸管,但还有其他一些事情需要检查:

  1. 确保MethodViewController.xib在您的项目中并包含在目标的“Copy Bundle Resources”阶段。有时,模拟器会设法神奇地找到文件系统中未正确包含在项目中的资源。

  2. 确保您的项目下的其他目录中没有MethodViewController.xib的旧副本。

  3. 确保MethodViewController.xib中的文件所有者设置为MethodViewController。

  4. 尝试构建 - >清理所有目标。