Hi all,
I need to share the data of a String variable between two view controllers. VC1 defines the variable, and then VC2 needs to have the variable to be able to work with it later.
My current code is this:
VC1:
VC2:
When called, VC2 prints:
Is there anything I'm doing wrong? VC2 doesn't print the variable, even though VC1 is printing it before I tap the button to segue to VC2.
Any help would be appreciated - thank you all so much in advance!
I need to share the data of a String variable between two view controllers. VC1 defines the variable, and then VC2 needs to have the variable to be able to work with it later.
My current code is this:
VC1:
Code Block Swift var myVariable: String = "" ... let myVariable = array.randomElement()
VC2:
Code Block Swift let firstVC = FirstViewController() let myVariable = homeVC.myVariable print("Data is \(myVariable)")
When called, VC2 prints:
Code Block text Data is
Is there anything I'm doing wrong? VC2 doesn't print the variable, even though VC1 is printing it before I tap the button to segue to VC2.
Any help would be appreciated - thank you all so much in advance!