I'm absolute newbie in Swift and OSX development, and I'm sorry if my question will be too noob. I want to understand principles of navigation between NSViewControllers.
I have my default ViewController
, where are login and password fields and button to login. After click on button, returns token. And now I trying to change "view" to SecondViewController
and save somewhere token, I will need it in future. How can I do it? and it possible to do this in function?:
@IBAction func loginButton(_ sender: Any) {
....
}
Thank you!
You need to use
segues
to perform this action.First make the
segues
connections between theViewControllers
using to storyboard editor. After that you need to give thesegues
an identifier on the storyboard's attributes inspector. Then in your code you can call the newViewController
by thesegue
like the code below.With this code you can pass the data using the button:
And with this code you will use the
override viewWillAppear
In both cases you need to assure the data you want to pass to the other view controller is not null.