2013-01-17 83 views
0

在VC1中嗨我有一個NSMutableArray顯示結果。即使用戶點擊到不同的選項卡(因此他們不必再次搜索),直到用戶再次搜索,我仍然希望保持該陣列活着。如何在切換到其他視圖控制器時保持NSArray可用

我有一個強大的指針,但它似乎卸載時,我離開了視圖。

沒有太多的代碼來顯示(_resultsArray從以前的控制器使用代理設置,所以它已經結果加載)

- (void)viewDidLoad 
    { 
     [super viewDidLoad]; 
     _resultsTableView.dataSource=self; 
     _resultsTableView.delegate=self; 
     [self.navigationController.navigationBar setHidden:YES]; 
    } 
//then standard tableview delegate methods... 

此代碼是試圖找出如何Segue公司標籤欄分享信息。 (在prepareforsegue)

當前在搜索VC。現在我有了我想要給resultsIndexVC的結果。下面的代碼嘗試這一點。 這是放置在當前(搜索VC)準備segue。

ResultsIndexViewController* vc = [[ResultsIndexViewController alloc] init]; 
     UITabBarController* tbc = [segue destinationViewController]; 
     vc = (ResultsIndexViewController *)[[tbc customizableViewControllers] objectAtIndex:1]; 
     vc.SearchDelegate=self;//crash here (normally works if using regular segue) 
     vc.resultsArray = _temporaryResultsArray; 
     vc.originalQuery=_queryArray; 

感謝

+0

顯示您的代碼。 – Apurv

+0

當你回到它時,你正在創建一個VC1的新實例嗎? – rdelmar

+0

爲什麼不在'AppDelegate'中保留'NSMutableArray'? – Sumanth

回答

0

問題是,我推着VC。相反,我使用了TabBar(在切換標籤頁時不釋放對象)

相關問題