I have followed the instruction in your book and I have made a simplest application to test an empty windows app with a window controller and xib file for this controller. I have wrote all necessary code according to the book but after building the app and closing the window of app I cannot reopen the window from Dock. What is wrong ? Below the code. (I deleted window in MainMenu.xib and accordingly changed AppDelegate; and Visible at Launch box is unchecked) ). The book says that showWindow(_ will reopen the window, but I don’t see this !
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var control: Control?
func applicationDidFinishLaunching(aNotification: NSNotification) {
//Create a window controller object
let control = Control()
//Put the window of the window controler om the screen
control.showWindow(self)
//Set the propertity to point to window controler
self.control = control
}
func applicationWillTerminate(aNotification: NSNotification) {
// Insert code here to tear down your application
}
}
in my controller class
import Cocoa
class Control: NSWindowController
{
override var windowNibName: String?
{
return “Control”
}
}
Learn to post code.
After you posted your code, did you not think to yourself: “That looks terrible, and it’s hard to read.” ?
I just tried to do what you describe with one of the examples I coded from the book, and there is nothing in the Dock that presents a way to reopen a closed window. What makes you think that is possible?
I also tried the same thing using TextEdit(an Apple text editing app), and what you describe cannot be done in TextEdit either. Are there any apps that you have used where that is possible?