functionToUpdate is a generic name. I don't know the name of update function you want to call.
So, in HerdViewController, you should have:
func functionToUpdate() {
// update the collectionView here
}
And in HorseViewController
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
if let vc1 = self.navigationController?.topViewController as? HerdViewController {
vc1.functionToUpdate()
}
}
May be you can pass the list of cells to update or to remove as a function parameter, to avoid reloading the full collectionView.
Note: effectively, you must not dismiss a view in a Navigation stack.
Topic:
Programming Languages
SubTopic:
Swift
Tags: