В моем быстром приложении, в котором есть эти функции, я не буду указывать класс, потому что это не важно.
class ViewController: UIViewController {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let destination = segue.destination as? LocalTVC,
let indexPath = tableView.indexPathForSelectedRow {
destination.selectedLocal = favouriteLocals[indexPath.row]
}
}
func presentLocalTVC() {
let storyBoard: UIStoryboard = UIStoryboard(name: "Home", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "localTVCID") as! LocalTVC
self.present(newViewController, animated: true, completion: nil)
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.presentLocalTVC()
}
Но когда в tableViewControlller, LocalTVC, представлены переменные "selectedLocal" равен nil,Как я могу решить это?