I have an app that utilizes multiple view controllers. One of the view controllers has a bunch of textFields that requests information from the user. This information is then passed to a .swift file that I made named "Variables.swift." Inside of this swift file, I created a struct named Variables and created all of my variables in it. For some reason, when I assign the data to the variables, the data is erased when I navigate through my other View Controllers.
In other words, look at it like this:
View Controllers: A -> B -> C -> D -> E -> F ... the information is gathered at View Controller "B", the user continues through the other view controllers (doing the delegated tasks) and then the information that they inputed at View Controller "B" is supposed to be displayed at View Controller "F." For some reason, when I get to View Controller F, the variables are completely empty... the data no longer stored in them - just gone.
Any help would be much appreciated... this is very frustrating. I'm passing the information via prepareForSegue.
Example (ignore the comments):
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
print("The info segue was executed.")
// let vc = autoPDFBuilder()
var variables = Variables()
if clientTextField.text != nil {
// vc.client = clientTextField.text!
// print(vc.client)
variables.client = clientTextField.text!
}
if claimNumberTextField.text != nil {
// vc.claimNumber = claimNumberTextField.text!
variables.claimNumber = claimNumberTextField.text!
}
if fileNumberTextField.text != nil {
// vc.fileNumber = fileNumberTextField.text!
variables.fileNumber = fileNumberTextField.text!
}
if lossDateTextField.text != nil {
// vc.dateOfLoss = lossDateTextField.text!
variables.dateOfLoss = lossDateTextField.text!
}
if insuredTextField.text != nil {
// vc.insured = insuredTextField.text!
variables.insured = insuredTextField.text!
}
if claimantTextField.text != nil {
// vc.claimant = claimantTextField.text!
variables.claimant = claimantTextField.text!
}
if picsByTextField.text != nil {
// vc.picsBy = picsByTextField.text!
variables.picsBy = picsByTextField.text!
}
if dateTakenTextField.text != nil {
// vc.dateTaken = dateTakenTextField.text!
variables.dateTaken = dateTakenTextField.text!
}
}