2010-04-05 14 views
0

我的應用程序在模擬器中工作正常,但是當我在我的手機上運行它,我得到這個錯誤:無法識別的選擇發送到實例

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'

它發生在這裏:

-(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

確實MethodViewController有referringObject財產? – Chuck 2010-04-05 20:52:42

+0

是的,它在模擬器中工作沒有錯誤,不明白爲什麼它不在手機上。 – iamsmug 2010-04-05 21:14:00

+0

用'@ property'定義顯示代碼行。 – 2010-04-05 21:49:35

回答

1

不知道爲什麼它的發生,但這種測試可能會產生一些有用的診斷信息:設置上都崩潰了行斷點,構建和調試您的手機上。然後在你的gdb提示符下鍵入「po methodViewController」,找出變量在運行時實際指向的對象類型。然後在模擬器中嘗試相同的事物並進行比較。出於某種原因,您可能在手機上收到了錯誤的課程對象。瞭解它的實際課程可能會有所幫助。

在抓救命稻草,但這裏有一些其他的事情來檢查:

  1. 確保MethodViewController.xib是在您的項目,並列入目標的「複製包資源」階段。有時候模擬器能夠在你的文件系統中奇蹟般地找到你的項目中沒有包含的資源。

  2. 確保你沒有MethodViewController.xib的舊副本在其他目錄圍坐項目下。

  3. 確保您的文件在MethodViewController.xib所有者設置爲MethodViewController。

  4. 嘗試構建 - >清理所有目標。

+0

感謝您的文章,它似乎只是修復自己,很奇怪! – iamsmug 2010-04-13 17:53:59

相關問題