Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This is the function that makes data passing possible
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
//1. Make sure you are using the correct segue
if segue.identifier == "ShowNameSegue" {
//2. Get the instance of your detail view from the segue's destination
//3. Get the index path for the row that the user tapped
if let detailViewController = segue.destination as? NameDetailViewController,
let indexPath = tableView.indexPathForSelectedRow {
//4. Initialize the word with indexPath
let name = names[indexPath.row]
//5. Pass the array to the detail view = name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment