开发者

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'

It happens here:

-(void)method {

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

 [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.na开发者_Python百科vigationController.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. Then type "po methodViewController" at your gdb prompt to find out what kind of object that variable actually points to at runtime. 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. 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.

  3. Make sure your File's Owner in MethodViewController.xib is set to MethodViewController.

  4. Try Build -> Clean All Targets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜