Last active
January 30, 2020 03:37
-
-
Save clc80/2b14c99adf0481d0386eddc24af6cf2a to your computer and use it in GitHub Desktop.
This is the function that makes data passing possible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
detailViewController.name = name | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment