DavidJames
DavidJames

Reputation: 11

Segue passing computed property data

I have 2 table view controllers - One is a registration input form the other a registration list form - and a model which is a computed property on the registration input form. Upon cell selection, how do I need to update the registration forms cells with the data of the selected registration using a segue?

Thanks in advance.

Upvotes: 0

Views: 35

Answers (1)

JLM
JLM

Reputation: 1

It sounds like you want to use the UIViewController prepare(for:sender:) instance method.

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "formSegue" {
            let destinationViewController = segue.destination as? DestinationViewController
            destinationViewController?.name = nameTextField.text
        }
    }

If you have multiple segues in your UIViewController then you need to give the segues identifiers in storyboard and check in the function which one was triggered, otherwise you don't need to check the segue.identifier. See Apple documentation here: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621490-prepareforsegue

Upvotes: 0

Related Questions