Created
March 7, 2021 02:05
-
-
Save Edudjr/b39df62f9020a387b375fa7ae839c49f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Composition root | |
let animals: [Animal] = [ | |
Dog(name: "Doggy", age: 3), | |
Horse(name: "Horsy", age: 5) | |
] | |
let pageDetails = PageDetails() | |
let vc = ListView(pageDetails: pageDetails, animals: animals) | |
// Then, once one animal is selected: | |
// ListView.swift | |
func tableView(_ tableView: UITableView, | |
didSelectRowAt indexPath: IndexPath) { | |
let animal = animals[indexPath.row] | |
pageDetails.animal = animal | |
present(pageDetails, animated: true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment