所以我有一個詳細信息視圖,需要通過從self.tableview中選定的單元格的indexpath中獲取索引整數來計算信息,我一直在使用NSFetchedResultsController self.tableview也是如此。我還實現了一個UISearchDisplayController來執行搜索。從UISearchDisplayController獲取self.tableview索引路徑tableView索引路徑
問題: 如何將UISearchDisplayController tableview中選定的indexPath轉換爲原始self.tableview的indexpath?或者我需要建立一個NSArray實例,並通過循環來找出索引?最有效的方法是什麼?
下面是代碼:
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
NSLog(@"display project details");
if (tableView == self.table) {
[parentController projectSelectedFromList:indexPath.row];
}else{
NSInteger index;
//what to put here? To get the indexPath of the self.table from search tableview
[parentController projectSelectedFromList:index];
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
謝謝。這基本上就是我所做的。技巧是找出NSFetchedResultsController的indexPathForObject方法。 :) – randomor