I have a single Window controller and 2 View Controllers.When the user clicks a button I need to open the second View Controller.I clicked and dragged a segue from the first view to the second view from a button.Now when the user clicks the Button the second View Controller opens up
Now I need to pass some data-Array of URLs from the first View Controller to the second.It seems that I need to override some function of the segue to achieve this
I have tried the following code from the answer related to IOS here How do you pass data between view controllers in Swift?
Since the classes are different for OSX,many classes are undefined
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
if (segue.identifier == "YourSegueName") {
//get a reference to the destination view controller
let destinationVC:ViewControllerClass = segue.destinationViewController as! ViewControllerClass
//set properties on the destination view controller
destinationVC.name = viewName
//etc...
}
}
So far I know how to override the segue preparation in OSX.I don't know how to identify the segue and pass the required data to the new ViewController.
override func prepare(for segue: NSStoryboardSegue, sender: Any?) {
}
Please advice.