Hi everybody,
As you know, I’m developing a native MacOS App with AppKit. This time I need to know how to open a new Window from a window and close the first window.
let me explain:
if you open Xcode you land on welcome screen. when you click on a button or cell of project, you close the welcome screen and open a new window. so, How can I do this?
Thank you
p.s. the creation of document have to be happen with the creation of new window, exactly like in Xcode. in Apple documentation there is this code:
override func makeWindowControllers() {
// Returns the storyboard that contains your document window.
let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil)
if let windowController =
storyboard.instantiateController(
withIdentifier: NSStoryboard.SceneIdentifier("Document Window Controller")) as? NSWindowController {
addWindowController(windowController)
// Set the view controller's represented object as your document.
if let contentVC = windowController.contentViewController as? ViewController {
contentVC.representedObject = content
contentViewController = contentVC
}
}
}
this code create the document with main windowviewcontroller. that means that in my case here I have to pass the content to HomeViewController that is the view controller that I want to open from the main view controller?