2016-11-13 55 views
-2

在之前斯威夫特有3個項目 - 如果我一直在尋找Segue公司從tableController的indexPath,我不得不像什麼替換Swift 3中的indexPathForSelectedRow?

 let indexPath = self.tableView.indexPathForSelectedRow! 

一行代碼然而,斯威夫特3,我不能寫這個。我似乎無法在蘋果網站或其他SO問題上找到任何文檔以找到可行的代碼片段。

爲了迴應Frankie的評論,我回到了我的代碼(這裏是所有當前的Swift 3代碼),並試圖複製和粘貼上面的代碼片段......但無濟於事。如果輸入「self.tableView」,Xcode不會自動完成。它不能識別indexPathForSelectedRow!無論是。我錯過了一些東西。

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    if segue.identifier == "dineSegue" 
    { 
     if let destinationViewController = segue.destination as? RestaurantController 
     { 
      let indexPath = DineController.indexPathForSelectedRow! 
      destinationViewController.restaurantIndex = index 
     } 
    } 
} 

回答

0

你確定了 「DineController」 引用的是實際的UITableView

當我有這個問題,我最初的參考是泛型類,而不是我編碼的實際表。