I'm working on project that has multiple view controllers, one of the view controllers has many text fields and a button which when you click it takes u to another view controller which is has map view. When a user selects a place on the map and afterwards tries to go back to the first view controller the previously populated textfields are empty.
How can i go back to the origin view controller and find the textfields and picker view still retaining the same values which were input initially before the segue.
here how i segue to second VC
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "toOnlyMap" {
let distenation = segue.destination as? onlyMapVC
distenation?.latitude = latitude
distenation?.longitude = longitude
}
}
@IBAction func toMapClicked(_ sender: UIButton) {
performSegue(withIdentifier: "toOnlyMap", sender: self)
}
here how i unwind the second VC
@IBAction func unwindToAdd(_ sender:UIStoryboardSegue) {
if latitude == 0.0 || longitude == 0.0 {
Helper.showAlert("Error", message: "you did not choose any place click back to dismiss this page", VC: self)
} else {
performSegue(withIdentifier: "backFromMap", sender: self)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "backFromMap" {
let destination = segue.destination as? addNotificationVC
destination?.latitude = latitude
destination?.longitude = longitude
destination?.color = "Ggreen"
destination?.theHint = "you have choose the location"
}
}