2014-03-03 119 views
0

我研究了Apple的«TableSearch»示例。在這個例子中,我們有一個«導航控制器»連接到一個viewController,包含一個«uiTableView»單元和一個«搜索欄»。TableSearch - 發送到實例的無法識別的選擇器

https://developer.apple.com/library/ios/samplecode/TableSearch/Listings/TableSearch_APLAppDelegate_m.html

我嘗試做的是不要把一些修正結構,並嘗試實施TableSearch在「的TabBar應用」。所以,現在我有一個«選項卡欄控制器»連接到一個「導航控制器」連接到包含uiTableView與«SearchBar的視圖控制器。在「Exception BreakPoint」的幫助下,我可以隔離一個問題「無法識別的選擇器發送到實例»。問題似乎在AppDelegate中,方法「application willFinishLaunchingWithOptions」。 任何幫助歡迎理解這個問題,謝謝。

UINavigationController *navigationController = (UINavigationController *)[self.window rootViewController]; 
APLViewController *viewController = [navigationController.viewControllers objectAtIndex:0]; 
viewController.products = productArray; //————<< problem HERE 
+0

您確定[navigationController.viewControllers objectAtIndex:0];你的情況是APLViewController嗎?它看起來不是。請給出的輸出:NSLog(@「%@」,[[navigationController.viewControllers objectAtIndex:0] class]); –

+0

2014-03-03 16:31:29.254 TableSearch [70950:70b] UIViewController 2014-03-03 16:31:29.255 TableSearch [70950:70b] - [UIViewController setProducts:]:無法識別的選擇器發送到實例0xcb2f0a0 – objM

+0

add一些控制檯日誌 – Rajesh

回答

0

基於信息你提供:

-[UIViewController setProducts:]: unrecognized selector sent to instance 

問題是,你的主要的viewController是UIViewController中,不APLViewController。 您需要在創建TabBarController時更新您的代碼

+0

好的,謝謝,我明白你的答案,但我真的不知道該怎麼做......我的故事板和所有連接似乎沒問題。山後的小山... – objM

+0

你必須創建一個擴展UIViewController的自定義類(與APLViewController相同),並將其作爲默認的UIViewController放入故事板 –

相關問題