How to close a window programmatically in Cocoa Mac?
问题 How can I programmatically close a window in cocoa mac ? I have opened a second window/xib from the first window/xib using button click. I need to close the first window/xib programmatically on opening or clicking the button. How can I do that? 回答1: Apple has some useful sample code on Nib Loading. It doesn't directly address this question however; the following code does. @interface CloseWindowAppDelegate : NSObject <NSApplicationDelegate> { NSWindow *window; IBOutlet NSWindow * secondWindow