Вам нужно только отправить indexPath напрямую
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let foodItemDetailController = FoodItemDetailController()
foodItemDetailController.foodItem = indexPath // if IndexPath is the type
navigationController?.pushViewController(foodItemDetailController, animated: true)
}
//
Или отправить элемент нажатием
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let all = allFoodItems[indexPath.section]
let item = all[indexPath.row]
let foodItemDetailController = FoodItemDetailController()
foodItemDetailController.foodItem = item // if foodItem is the type
navigationController?.pushViewController(foodItemDetailController, animated: true)
}