0

I followed this solution and I was able to get it to work successfully:

how to get document id on tapping the uitablecellviewcell in Firestore in swift

However, now my challenge is how do I pass the documentID to the next view controller on Segue? I understand I have to use the following function:

 override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

Also how do I call the documentID in the next view controller?

I would truly appreciate any advice you may be able to provide. Thank you!

Ron
  • 29
  • 6

1 Answers1

0

If you are using storyboard segues, then in the function you can write

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    guard let detailVC = segue.destination as? UIViewControllerDetail else{
        return
    }
    detailVC.documentID = documentID
}

Where UIViewControllerDetail is the viewcontroller class that gets presented when the user taps on the cell. In the UIViewController detail, make sure to add the documentID property

var documentID: String?
Luca Sfragara
  • 624
  • 4
  • 16