so I am developing an app and also learning swift at the same time. I have figured out how to send data from secondViewController to the firstViewController. Essentially I have linked the "done" button to the firstViewController, so when I press "Done", it opens up a new window of the first viewController and gives the data that I have passed.
However, I am looking for a way to update the firstViewController without having another window of it opened with a different segue.
The best way to explain this is that my firstViewController has an "add" button that opens up secondViewController. This viewController has two textfields, you write stuff in it (I want stuff written in these two textbox to appear on the first viewController) & then when you press done, the secondViewController dismisses and you are back on the firstViewController.
This is the code that I am using : (in the secondViewController)
override func prepare(for segue: NSStoryboardSegue, sender: Any?) {
var destinationviewcontroller : ViewController = segue.destinationController as! ViewController
destinationviewcontroller.LabelText = weblinklabel.stringValue
}
Obviously labeltext
is a label in the firstviewcontroller that shows what is written in those textfields in the secondViewController.
The problem is when I use storyboard and simply drag from "Done" button to the firstViewController, it opens the firstViewController in a new window with the new data/updated labeltext
. I want the secondViewController to just dismiss when I press "Done" and the updated label to appear on the firstViewController without it being opened in the new window.
It's a bit difficult to explain, so if you need some more details for clarification, I will be more than happy to give it!
Thanks in advance!