我有一個名爲DataViewController的子視圖和一個稱爲RootViewController的父視圖控制器。親子無法識別的選擇器發送到實例
每次是試圖調用一個函數或設置在我的RootViewController的定義,從我的子視圖屬性,我得到這些錯誤:
錯誤:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPageViewController setDetailsDataObject:]: unrecognized selector sent to instance 0x6aa2df0'
代碼:
RootViewController.h:
@property (strong, nonatomic) id detailsDataObject;
DataViewController.m:
((RootViewController *)self.parentViewController).detailsDataObject = self.dataObject;
而且......
錯誤:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPageViewController showDetails]: unrecognized selector sent to instance 0x6880db0'
代碼:
RootViewController.h:
- (void)showDetails;
RootViewController.m:
- (void)showDetails
{
NSLog(@"Hello");
}
DataViewController.m:
[((RootViewController *)self.parentViewController) showDetails];
有誰知道如何解決這些例外?
感謝您的回覆,我對xcode和iOS開發相當陌生,所以我從來沒有聽說過NSAssert或如何使用它,特別是在這種情況下。你能幫我多一些嗎? – user1026090 2012-01-18 15:19:36
再次檢查我的答案..編輯了 – Shubhank 2012-01-18 15:27:16
謝謝你的幫助,斷言失敗:斷言失敗 - [DataViewController handleSingleDoubleTap:],/Users/kevincuppens/Desktop/Catalogus/Catalogus/DataViewController.m:83 2012-01- 19 08:42:47.935目錄[6063:f803] ***終止應用程序,由於未捕獲的異常'NSInternalInconsistencyException',原因:'Not RootViewController' – user1026090 2012-01-19 07:45:00