0

Good day all, Eight months ago someone asked almost the same question but there is no answer. My MacOS has been rejected because the Window menu item does not have a menu item that re-open the MacOS app if we close it by using the red dot located on the top left corner. I have created a menu item that I linked to an IBACtion to show the ContentView() (Home Page). It works fine when the App is runing and you can come back to the home page if you click on this button item (code below). But what code to use to re-open the App? Thanks in advance.

@IBAction func DisplayHomePAge(_ sender: NSMenuItem) {
window.contentView = NSHostingView(rootView: ContentView())
}
Wild8x
  • 459
  • 4
  • 13

1 Answers1

0

Finally Here is the code for the IBAction:

@IBAction func DisplayHomePAge(_ sender: NSMenuItem) {
let url = URL(fileURLWithPath: Bundle.main.resourcePath!)
let path = url.deletingLastPathComponent().deletingLastPathComponent().absoluteString
let task = Process()
task.launchPath = "/usr/bin/open"
task.arguments = [path]
task.launch()
exit(0)
}

I found this code at this link:

enter link description here

Wild8x
  • 459
  • 4
  • 13