Passing Data Between Controllers in Swift and the “Green Island” trip in summer holidays

It has been 10 years since I had my trip to “Green Island”. It’a little island in the Pacific Ocean about 33 km (21 mi) off the eastern coast of Taiwan with a stunning milky way galaxy night view in the poetic summer holidays.

Func prepare is a built-in function notifies the view controller that a segue is about to be performed. And passing data in the prepare function makes it a lot easier than adding passing data code in every button action function if multiple buttons and segues need to be performed.


override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// type transfer from UIViewController to target ViewController //let editTableViewController = segue.destination as? EditTableViewController// pass the data "islands(array)" to target ViewController by clicking the table cell if let indexPath = tableView.indexPathForSelectedRow{editTableViewController?.island = islands[indexPath.row]}}

--

--