Skip to content

Instantly share code, notes, and snippets.

@Edudjr
Created March 7, 2021 02:05
Show Gist options
  • Save Edudjr/b39df62f9020a387b375fa7ae839c49f to your computer and use it in GitHub Desktop.
Save Edudjr/b39df62f9020a387b375fa7ae839c49f to your computer and use it in GitHub Desktop.
// 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